Teodor is not a liar!

题意翻译

给定大整数闭区间 $[1,m]$ 和 $n$ 个属于大区间的小整数闭区间。最多能进行多少次询问——每次询问一个未曾询问过的整数 $k \in[1,m]$ ,回答有多少个小区间包含整数 $k$ ——使得在这些询问后,**依然不能确定没有一个属于大区间的整数被所有的小区间包含**。 注意, **的确不存在这样的一个整数,而且询问者一开始并不清楚有多少个小区间。**

题目描述

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.

输入输出格式

输入格式


First line of input contains two integer numbers: $ n $ and $ m $ ( $ 1<=n,m<=100000 $ ) — 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.

输出格式


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 $ ).

输入输出样例

输入样例 #1

2 4
1 2
3 4

输出样例 #1

4

输入样例 #2

4 6
1 3
2 3
4 6
5 6

输出样例 #2

5

说明

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.