Mowing the Field

Count interior crossings of perpendicular mower segments cut at least T days apart.

Hard8Segment treeGeometrySliding windowNo attempts yetTime limit5sMemory limit512 MB

Problem

Farmer John runs his farm well in almost every way, except that he is always late with the mowing. He moves the mower only once a day. On day 1 he starts at (x1,y1)(x_1, y_1), and on day dd he mows along a straight segment from the previous day's position to (xd,yd)(x_d, y_d). On the 2D map of the farm every move is horizontal or vertical, so xd=xd1x_d = x_{d-1} or yd=yd1y_d = y_{d-1}. John alternates horizontal and vertical moves on successive days.

He works so slowly that grass he already cut grows back before he is done. Grass cut on day dd reappears on day d+Td + T, so whenever his path meets a segment he cut at least TT days earlier, he cuts the same spot a second time. John wants to know how bad his routine is, so he wants to count how often that happens.

Count the crossing points where John re-cuts grass that had grown back. Only perpendicular meetings count, meaning a point shared by a horizontal segment and a vertical segment that is an endpoint of neither segment.

Input

The first line contains NN (2N1000002 \le N \le 100\,000) and TT (1TN1 \le T \le N, TT even).

Each of the next NN lines gives the position of the mower on days 11 through NN. Line ii contains the integers xix_i and yiy_i, both between 00 and 10910^9.

Two consecutive positions may be equal. The move on such a day is a single point and takes part in no crossing.

Output

Print the number of crossing points described above.

Hint

In the first example the path of day 7 meets the segment cut on day 2. The two days are T=4T = 4 or more apart, so this crossing counts. The other two crossings are only 3 days apart and do not count.