#3314. [Usaco2013 Nov] Crowded Cows

[Usaco2013 Nov] Crowded Cows

Description

Farmer John's NN cows are grazing along a one-dimensional fence. Cow i is standing at location xix_i and has height hih_i.

A cow feels "crowded" if there is another cow at least twice her height within distance DD on her left, and also another cow at least twice her height within distance DD on her right. Since crowded cows produce less milk, Farmer John would like to count the number of such cows. Please help him.

Input

Line 11: Two integers, NN and DD.

Lines 21+N2\sim 1+N: Line i+1i+1 contains the integers xix_i and hih_i. The locations of all NN cows are distinct.

Output

Line 11: The number of crowded cows.

6 4
10 3
6 2
5 3
9 7
3 6
11 2
2

Sample Explain 1

There are 66 cows, with a distance threshold of 44 for feeling crowded. Cow #11 lives at position x=10x=10 and has height h=3h=3, and so on.

The cows at positions x=5x=5 and x=6x=6 are both crowded.

Data scale and Agreement

For 100%100\% data, 1N5×1041\leq N\leq 5\times 10^4, 1xi,hi,D1091\leq x_i,h_i,D\leq 10^9.

Source

Silver