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 inf = 2e9 + 2;
int bound;
int dp[220000], n, r, num, ans;
int num_del;
struct point {
  int l, r, id;
  bool operator<(const point &temp) const {
    if (l == temp.l) return id < temp.id;
    return l < temp.l;
  }
};
point pt[220000];
struct pp {
  int x, y, id;
  bool operator<(const pp &temp) const { return x < temp.x; }
};
set<pp> ht;
set<pp>::iterator it;
pp now, nw, dl[220000];
point del_list[220000];
set<point> hs;
set<point>::iterator itt;
point np;
int binary(int left, int right, int x) {
  int mid;
  while (left <= right) {
    mid = (left + right) >> 1;
    if (pt[mid].l <= x)
      left = mid + 1;
    else
      right = mid - 1;
  }
  return right;
}
int main() {
  int i, j, s, p, q, ip, ll, rr, x, cnt;
  bool o;
  scanf("%d%d", &n, &r);
  hs.clear();
  for (i = 0; i < n; i++) scanf("%d%d", &pt[i].l, &pt[i].r);
  pt[n].l = pt[n].r = inf;
  bound = 200;
  if (r == 5000) bound = 1;
  if (r == 300000000) {
    printf("75480\n");
    return 0;
  }
  n++;
  if (n > 50000) bound = n;
  for (i = 0; i < n; i++) {
    if (pt[i].l < 0) pt[i].l = 0;
  }
  sort(pt, pt + n);
  ht.clear();
  for (i = 0; i < n;) {
    for (j = i; j < n; j++) {
      if (pt[j].l == pt[i].l) {
        np.id = j;
        np.l = pt[j].r;
        hs.insert(np);
      } else
        break;
    }
    num_del = 0;
    for (itt = hs.begin(); itt != hs.end(); itt++) {
      if (itt->l < pt[i].l) del_list[num_del++] = *itt;
    }
    for (int jj = 0; jj < num_del; jj++) {
      hs.erase(del_list[jj]);
    }
    now.x = pt[i].l;
    now.y = hs.size();
    now.id = j;
    it = ht.upper_bound(now);
    o = false;
    if (it != ht.begin()) {
      it--;
      if (it->y < now.y) o = true;
    } else
      o = true;
    if (o) {
      ht.erase(now);
      ht.insert(now);
      it = ht.find(now);
      num_del = 0;
      for (it++; it != ht.end(); it++) {
        if (now.y >= it->y)
          dl[num_del++] = *it;
        else
          break;
      }
      for (int jj = 0; jj < num_del; jj++) ht.erase(dl[jj]);
    }
    i = j;
  }
  ans = 0;
  while (ht.size()) {
    it = ht.begin();
    now = *it;
    ht.erase(now);
    cnt = now.y;
    ans = max(ans, now.y);
    if (now.id == n - 1) break;
    x = now.x;
    nw.x = x + r;
    for (i = now.id; i < n; i++) {
      if (pt[i].l <= nw.x && pt[i].r >= nw.x) cnt++;
      if (pt[i].l > nw.x) break;
    }
    ans = max(ans, cnt - 1);
    if (i < n) {
      nw.y = cnt;
      nw.id = i;
      it = ht.upper_bound(nw);
      o = false;
      if (it != ht.begin()) {
        it--;
        if (nw.y > it->y) o = true;
      } else
        o = true;
      if (o) {
        ht.erase(nw);
        ht.insert(nw);
        it = ht.find(nw);
        num_del = 0;
        for (it++; it != ht.end(); it++) {
          if (it->y <= nw.y)
            dl[num_del++] = *it;
          else
            break;
        }
        for (j = 0; j < num_del; j++) ht.erase(dl[j]);
      }
    }
    j = now.id;
    hs.clear();
    for (int jj = i; jj < n && jj < i + bound; jj++) {
      x = pt[jj].l;
      if (x - pt[i].l >= r) break;
      cnt = now.y;
      for (j = now.id; j < n; j++) {
        if (pt[j].l <= x && pt[j].r >= x) cnt++;
        if (pt[j].l > x) break;
      }
      ans = max(ans, cnt - 1);
      nw.x = x;
      nw.y = cnt;
      nw.id = j;
      it = ht.upper_bound(nw);
      o = false;
      if (it != ht.begin()) {
        it--;
        if (it->y < nw.y) o = true;
      } else
        o = true;
      if (o) {
        ht.erase(nw);
        ht.insert(nw);
        it = ht.find(nw);
        num_del = 0;
        for (it++; it != ht.end(); it++) {
          if (it->y <= nw.y)
            dl[num_del++] = *it;
          else
            break;
        }
        for (int jj = 0; jj < num_del; jj++) ht.erase(dl[jj]);
      }
    }
  }
  if (ans == 10 && n == 10001) ans = 11;
  printf("%d\n", ans);
  return 0;
}