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 = 200005;
const int M = 6000005;
int n, d, nd, rt, pre;
int ls[M], rs[M];
int tg[M], t[M];
priority_queue<pair<int, int> > q;
void add(int &k, int l, int r, int x, int y) {
  if (!k) return;
  if (x <= l && r <= y) return ++tg[k], ++t[k], void(0);
  int mid = (l + r) / 2;
  if (x <= mid) add(ls[k], l, mid, x, y);
  if (y > mid) add(rs[k], mid + 1, r, x, y);
  t[k] = max(t[ls[k]], t[rs[k]]) + tg[k];
}
void change(int &k, int l, int r, int x, int p) {
  if (!k) k = ++nd;
  if (l == r) return t[k] = p, void(0);
  int mid = (l + r) / 2;
  if (x <= mid)
    change(ls[k], l, mid, x, p);
  else
    change(rs[k], mid + 1, r, x, p);
  t[k] = max(t[ls[k]], t[rs[k]]) + tg[k];
}
int ask(int k, int l, int r, int x, int y) {
  if (!k || y < l || x > r) return 0;
  if (x <= l && r <= y) return t[k];
  int mid = (l + r) / 2;
  if (y <= mid) return ask(ls[k], l, mid, x, y) + tg[k];
  if (x > mid) return ask(rs[k], mid + 1, r, x, y) + tg[k];
  return max(ask(ls[k], l, mid, x, mid), ask(rs[k], mid + 1, r, mid + 1, y)) +
         tg[k];
}
int main() {
  scanf("%d%d", &n, &d);
  for (int i = (int)(1); i <= (int)(n); i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    l = max(0, l);
    q.push(pair<int, int>(-r, -l));
    q.push(pair<int, int>(-l, 1));
  }
  pre = -1;
  t[0] = -(1 << 30);
  while (!q.empty()) {
    int l = -q.top().second;
    int r = -q.top().first;
    q.pop();
    if (l >= 0)
      add(rt, 0, 1e9, l, r);
    else {
      if (r == pre) continue;
      int u = ask(rt, 0, 1e9, pre, pre);
      int v = ask(rt, 0, 1e9, 0, r - d);
      if (l == -1 || u < v) {
        pre = r;
        change(rt, 0, 1e9, r, v);
        if (r + d <= 1e9) q.push(pair<int, int>(-r - d, 2));
      }
    }
  }
  printf("%d\n", t[1]);
}