Problem: A duck hunter is doing his favorite thing, hunting. He lives in a two dimensional world and is located at point (0, 0). As he doesn't like walking for his prey, he prefers to shoot only vertically up (because in this case, the ducks fall straight into his hands). The hunter doesn't reload the gun immediately — r or more seconds must pass between the shots. When the hunter shoots up, the bullet immediately hits all the ducks who 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 Ox axis at the speed 1 length unit per second. For each duck we know the values hi and ti — the x-coordinates of its head (the left end of the segment) and its tail (the right end of the segment) at time 0. The height where the duck is flying isn't important as the gun shoots vertically up to the infinite height and hits all the ducks on its way. 

<image> The figure to the first sample.

What maximum number of ducks can the hunter shoot? The duck is considered shot by the hunter if at the moment of the shot at least one of its point intersects the Oy axis. After the hunter shoots the duck, it falls and it can't be shot anymore. The hunter cannot make shots before the moment of time 0.

Input

The first line of the input contains integers n, r (1 ≤ n ≤ 200 000, 1 ≤ r ≤ 109) — the number of ducks and the minimum time in seconds between the shots. 

Then n lines follow, each of them contains two integers hi, ti ( - 109 ≤ hi < ti ≤ 109) — the x-coordinate of the head and tail of the i-th duck at the moment 0.

Output

Print a single integer — the maximum number of ducks that can be shot by the hunter.

Examples

Input

3 3
-3 0
1 3
-1 2


Output

3


Input

4 5
-1 1
2 4
5 9
6 8


Output

3

Note

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

In the second sample the hunter can make shots at times 0 and 6 to hit three ducks.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 2;
const int MX = 6e6 + 2;
const int inf = 1e9 + 7;
int ls[MX], rs[MX], sz = 1, lz[MX], t[MX];
priority_queue<pair<int, int> > lis;
void push(int idx) { t[idx] = max(t[ls[idx]], t[rs[idx]]) + lz[idx]; }
void change(int &idx, int l, int r, int p, int v) {
  if (l > p || r < p) {
    return;
  }
  if (!idx) {
    idx = ++sz;
  }
  if (l == r) {
    t[idx] = v;
    return;
  }
  int mid = (l + r) / 2;
  if (p <= mid) {
    change(ls[idx], l, mid, p, v);
  } else {
    change(rs[idx], mid + 1, r, p, v);
  }
  push(idx);
}
void add(int &idx, int l, int r, int lef, int rig) {
  if (!idx || l > rig || r < lef) {
    return;
  }
  if (l >= lef && r <= rig) {
    lz[idx]++;
    t[idx]++;
    return;
  }
  int mid = (l + r) / 2;
  add(ls[idx], l, mid, lef, rig);
  add(rs[idx], mid + 1, r, lef, rig);
  push(idx);
}
int get(int &idx, int l, int r, int lef, int rig) {
  if (!idx || l > rig || r < lef) {
    return 0;
  }
  if (l >= lef && r <= rig) {
    return t[idx];
  }
  int mid = (l + r) / 2, ans = get(ls[idx], l, mid, lef, rig);
  ans = max(ans, get(rs[idx], mid + 1, r, lef, rig));
  return ans + lz[idx];
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, i, j, k, l, r, v, pre, d, rt = 1;
  cin >> n >> d;
  for (i = 1; i <= n; i++) {
    cin >> j >> k;
    j = max(j, 0);
    lis.push({-k, -j});
    lis.push({-j, 1});
  }
  pre = -1;
  t[1] = -inf;
  while (lis.size()) {
    l = -lis.top().second, r = -lis.top().first;
    lis.pop();
    if (l >= 0) {
      add(rt, 0, 1e9, l, r);
    } else {
      if (pre == r) {
        continue;
      }
      j = get(rt, 0, 1e9, pre, pre);
      k = get(rt, 0, 1e9, 0, r - d);
      if (l == -1 || j < k) {
        pre = r;
        change(rt, 0, 1e9, pre, k);
        if (r + d <= 1e9) {
          lis.push({-r - d, 2});
        }
      }
    }
  }
  cout << t[1];
}