시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB6311714.000%

문제

Zoran wanders across his Dalmatian homeland to forget his love woes. He came across a mountain of a specific shape, behind which a young maiden is waiting for him. The mountain can be described with n alternating low and high points, where n is odd. Points at odd indices, except the first and the last point, are called valleys.

Zoran is afraid of the dark. Even the call of love will not give him courage to cross the mountain at night. As usual, the fairies of Velebit come to the rescue.

We model each fairy by a luminous dot at a fixed height h. A fairy illuminates the valley if and only if the segment connecting the fairy and the valley does not intersect the interior of the mountain.

The mountain from the first example, and a fairy illuminating all three valleys.

What is the least number of fairies which can illuminate all the valleys simulaneously?

입력

The first line contains two integers n (3 ≤ n < 106, n odd) and h (1 ≤ h ≤ 106), the number of points describing the mountain and the height the fairies live at.

The i-th of the following n lines contains integers xi and yi (−106 ≤ xi ≤ 106, 0 ≤ yi < h), the coordinates of the i-th point of the mountain.

It is guaranteed that x1 < x2 < · · · < xn, and y1 < y2, y2 > y3, y3 < y4, . . ., yn−1 > yn.

출력

Output the least number of fairies such that all valleys are illuminated.

서브태스크

번호배점제한
120

y2 = y4 = · · · = yn−1

230

3 ≤ n < 2000

360

No additional constraints.

예제 입력 1

9 6
0 0
1 2
3 0
6 3
8 1
9 2
11 1
12 4
14 0

예제 출력 1

1

예제 입력 2

9 5
-5 2
-4 3
-2 1
0 4
2 2
3 3
4 1
5 2
6 1

예제 출력 2

2

힌트

The first example is shown in the statement. It can be shown that the valleys in the second example cannot be illuminated using only one fairy. An example with two fairies is given on the figure below.

채점 및 기타 정보

  • 예제는 채점하지 않는다.