Codeforces Round 468 (Div. 2, based on Technocup 2018 Final Round)
F
Teodor is not a liar!
Codeforces
未评级
原题
← E→
翻译中…

Young Teodor enjoys drawing. His favourite hobby is drawing segments with integer borders inside his huge $[1;*m*]$ segment. One day Teodor noticed that picture he just drawn has one interesting feature: there doesn't exist an integer point, that belongs each of segments in the picture. Having discovered this fact, Teodor decided to share it with Sasha.

翻译中…

Sasha knows that Teodor likes to show off so he never trusts him. Teodor wants to prove that he can be trusted sometimes, so he decided to convince Sasha that there is no such integer point in his picture, which belongs to each segment. However Teodor is lazy person and neither wills to tell Sasha all coordinates of segments' ends nor wills to tell him their amount, so he suggested Sasha to ask him series of questions 'Given the integer point $*x*_{*i*}$, how many segments in Fedya's picture contain that point?', promising to tell correct answers for this questions.

翻译中…

Both boys are very busy studying and don't have much time, so they ask you to find out how many questions can Sasha ask Teodor, that having only answers on his questions, Sasha can't be sure that Teodor isn't lying to him. Note that Sasha doesn't know amount of segments in Teodor's picture. Sure, Sasha is smart person and never asks about same point twice.

翻译中…

Input

翻译中…

First line of input contains two integer numbers: $*n*$ and $*m*$ ($1 ≤ *n*, *m* ≤ 100 000$) — amount of segments of Teodor's picture and maximal coordinate of point that Sasha can ask about.

翻译中…

$*i*$th of next $*n*$ lines contains two integer numbers $*l*_{*i*}$ and $*r*_{*i*}$ ($1 ≤ *l*_{*i*} ≤ *r*_{*i*} ≤ *m*$) — left and right ends of $*i*$th segment in the picture. Note that that left and right ends of segment can be the same point.

翻译中…

It is guaranteed that there is no integer point, that belongs to all segments.

翻译中…

Output

翻译中…

Single line of output should contain one integer number $*k*$ – size of largest set $(*x*_{*i*}, *cnt*(*x*_{*i*}))$ where all $*x*_{*i*}$ are different, $1 ≤ *x*_{*i*} ≤ *m*$, and $*cnt*(*x*_{*i*})$ is amount of segments, containing point with coordinate $*x*_{*i*}$, such that one can't be sure that there doesn't exist point, belonging to all of segments in initial picture, if he knows only this set(and doesn't know $*n*$).

翻译中…

Note

翻译中…

First example shows situation where Sasha can never be sure that Teodor isn't lying to him, because even if one knows $*cnt*(*x*_{*i*})$ for each point in segment $[1;4]$, he can't distinguish this case from situation Teodor has drawn whole $[1;4]$ segment.

翻译中…

In second example Sasha can ask about 5 points e.g. $1, 2, 3, 5, 6$, still not being sure if Teodor haven't lied to him. But once he knows information about all points in $[1;6]$ segment, Sasha can be sure that Teodor haven't lied to him.

翻译中…

样例

Input #1
2 4
1 2
3 4
Output #1
4
InputCopy OutputCopy
Input #2
4 6
1 3
2 3
4 6
5 6
Output #2
5
InputCopy OutputCopy
题目信息
题号
931F
时间限制
1 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。