Zhenya the Glider Pilot
A plane is flying parallel to the Earth's surface at a height of h meters. The plane travels from point (−10^9
, h) to point (10^9
, h) along the Ox axis, moving to the right.
Onboard the plane is a glider named Zhenya, who will jump out at a specific moment. For this task, the glider can only jump from integer coordinates. After jumping, each second, he moves one unit to the right along the Ox axis and descends one unit downward.
There are several segments with updrafts, each defined by two numbers x[1]
and x[2]
(x1 < x2), which extend vertically through the entire height. No two updrafts overlap or touch. When the glider enters an updraft, he maintains his altitude while within it, although he continues to move one unit to the right per second. Your task is to determine the maximum distance along the Ox axis that the glider can travel from his jump point to his landing point, given that he can choose his jump point freely. Once the glider reaches the ground, he stops, meaning he cannot continue gliding in an updraft at height 0.
For example, if the glider jumps at coordinate 1, he will land at 10. If he jumps at coordinate 2, he will land at 12.
Input
The first line contains two integers n and h (1 ≤ n ≤ 2⋅10^5
, 1 ≤ h ≤ 10^9
) - the number of updrafts and the flight height of the plane.
Each of the next n lines contains two integers xi1 and xi2 (1 ≤ xi1 < xi2 ≤ 10^9) - the coordinates of the left and right ends of the i-th updraft. It is guaranteed that no two updrafts intersect or share common points.
Output
Print the maximum distance along the Ox axis from the jump point to the landing point that the glider can achieve, given that he can choose his jump point freely. It is guaranteed that the answer is an integer under the given constraints.
Examples
Note
In the first example, it is optimal for the glider to jump at the point with coordinates (2,4), landing at (12,0). The distance is 12 − 2 = 10. In the second example, the best jump is at (16,10), landing at (34,0), resulting in a distance of 34−16=18. In the third example, the glider can jump at (−100, 1000000000), landing at (1999999899, 0), with a distance of 1999999899 − (−100) = 1999999999.