RETO3M10 - 6RETO 10 MARATON

no tags 

A duck hunter is doing his favorite thing, hunting. He lives in a world of two dimensions and is situated at the point (0, 0). As he does not like walking around his prey, he prefers to shoot only vertically (up), because in this case, the ducks fall directly into his hands. After each shot the hunter is not able to reload immediately - r more seconds must elapse after the last shot. When the hunter shoots the bullet strikes immediately all the ducks that are directly above the hunter.

In a two dimensional world each duck is a horizontal segment that moves horizontally in the negative direction of the X-axis with a speed of 1 unit length per second. For each duck, we know the x coordinate of its head (the left end of the segment) and tail (the right end of the segment) at time 0. The height at which the duck is flying is not important because gun shoots vertically to an infinite height and hits it ducks all in its path.

Disparo

Figure the first shot.

What is the maximum number of ducks that can be shot?

A duck is considered shot if at the time of shooting at least one of its points is across the axis. After the duck hunter shoots down and he can not shoot more. The hunter can not make shots before 0 point in time.

Input

The first line of input contains integers:

n, r (1 ≤ n ≤ 200000, 1 ≤ r ≤ 109)

  • n the number of ducks
  • r the minimum time in seconds between shots.

Then the n lines follow, each containing two integers:

hi, ti (-109 ≤ hi i ≤ 109)

  • The x coordinate of the head and tail of the i-th duck at time 0.

Output

Print a single integer - the maximum number of ducks that can be shot.

Example

Input:
3 3
-3 0
1 3
-1 2

Output:
3
Input:
4 6
-1 1
2 4
5 9
6 8

Output:
3

Explanation

In the first example the hunter must shoot at time 0, this shot kills ducks 1 and 3. Then the hunter needs to reload and shoot again in time 3. His second shot hits the duck 2 tail.

The second example shows the hunter can shoot at times 0 and 6 to hit three ducks.


hide comments
wisfaq: 2015-09-28 13:50:22

unnecessary language restrictions


Added by:MARATON AFDM
Date:2015-09-28
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:MAWK BC C NCSHARP CSHARP C++ 4.3.2 COFFEE DART FORTH JAVA JS-RHINO JULIA KTLN NODEJS OCT PHP PROLOG PYPY3 R RACKET SQLITE SWIFT UNLAMBDA