loj#P3466. 「COCI 2021.2」Planine

「COCI 2021.2」Planine

Description

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 nn alternating low and high points, where nn is odd. Points at odd indices, except the first and the last point, are called valleysvalleys.

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 hh. 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?

Input

The first line contains two integers nn (3n<106,(3 \le n < 10^6, nn odd)) and hh (1h106)(1 \le h \le 10^6 ), the number of points describing the mountain and the height the fairies live at.

The ii-th of the following nn lines contains integers xix_i and yiy_i (106xi106,0yi<h)(−10^6 \le x_i \le 10^6 , 0 \le y_i < h), the coordinates of the ii-th point of the mountain.

It is guaranteed that x1<x2<<xnx_1 < x_2 < \cdots < x_n, and y1<y2,y2>y3,y3<y4,,yn1>yny_1<y_2,y_2>y_3,y_3<y_4,\ldots,y_{n-1}>y_n.

Output

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

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

Scoring

Subtask Constraints Points
11 y2=y4==yc1y_2=y_4=\cdots=y_{c-1} 20/11020/110
22 n<2×103n<2\times 10^3 30/11030/110
33 No additional constraints. 60/11060/110