Crowded Cows

No attempts yetTime limit1sMemory limit128 MB

Problem

Farmer John's NN cows are grazing along a straight fence. Cow ii stands at position xix_i and has height hih_i.

A cow feels crowded when some cow at least twice her height stands within distance DD to her left and some cow at least twice her height also stands within distance DD to her right. Her left side is the range of positions from xiDx_i - D up to but not including xix_i, and her right side is the range above xix_i up to and including xi+Dx_i + D.

Crowded cows give less milk. Help Farmer John count how many of them there are.

  • 1N500001 \le N \le 50000
  • 1xi,hi1091 \le x_i, h_i \le 10^9
  • 1D1091 \le D \le 10^9

Input

The first line has two integers NN and DD.

Each of the next NN lines has the position xix_i and the height hih_i of cow ii. All positions are distinct. The input is not guaranteed to be sorted by position.

Output

Print the number of crowded cows on one line.

Hint

The example has 6 cows and a distance threshold of D=4D = 4. The first cow stands at position 10 with height 3, and the remaining lines read the same way. The cows at positions 5 and 6 feel crowded, so the answer is 2.