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 MAX = 200100, MIL = 1000000100;
const unsigned int TOUR = 1 << 21;
struct event {
  int t, ind, st;
};
bool operator<(const event &a, const event &b) {
  if (a.t != b.t) return a.t > b.t;
  if (a.st != b.st) return a.st > b.st;
  return a.ind > b.ind;
}
struct node {
  int maxx, prop;
  node *l, *r;
};
int vremena[10 * MAX], indvr;
struct tour {
  node *root, *NIL;
  tour() {
    NIL = new node{0, 0, NIL, NIL};
    NIL->l = NIL->r = NIL;
    root = new node{0, 0, NIL, NIL};
  }
  void propagiraj(node *p) {
    if (p->l == NIL) p->l = new node{0, 0, NIL, NIL};
    p->l->maxx += p->prop;
    p->l->prop += p->prop;
    if (p->r == NIL) p->r = new node{0, 0, NIL, NIL};
    p->r->maxx += p->prop;
    p->r->prop += p->prop;
    p->prop = 0;
  }
  void set(node *p, unsigned int lo, unsigned int hi, unsigned int poz,
           int val) {
    if (lo >= poz + 1 || hi <= poz) return;
    if (lo == poz && hi == poz + 1) {
      p->maxx = max(p->maxx, val);
      return;
    }
    propagiraj(p);
    set(p->l, lo, (lo + hi) / 2, poz, val);
    set(p->r, (lo + hi) / 2, hi, poz, val);
    p->maxx = max(p->l->maxx, p->r->maxx);
  }
  void set(unsigned int poz, int val) { set(root, 0, TOUR, poz, val); }
  void insert(node *p, unsigned int lo, unsigned int hi, unsigned int begin,
              unsigned int end, int val) {
    if (lo >= end || hi <= begin) return;
    if (lo >= begin && hi <= end) {
      p->maxx += val;
      p->prop += val;
      return;
    }
    propagiraj(p);
    insert(p->l, lo, (lo + hi) / 2, begin, end, val);
    insert(p->r, (lo + hi) / 2, hi, begin, end, val);
    p->maxx = max(p->l->maxx, p->r->maxx);
  }
  void insert(unsigned int begin, unsigned int end, int val) {
    insert(root, 0, TOUR, begin, end, val);
  }
  int query(node *p, unsigned int lo, unsigned int hi, unsigned int begin,
            unsigned int end) {
    if (lo >= end || hi <= begin) return 0;
    if (lo >= begin && hi <= end) return p->maxx;
    propagiraj(p);
    return max(query(p->l, lo, (lo + hi) / 2, begin, end),
               query(p->r, (lo + hi) / 2, hi, begin, end));
  }
  int query(unsigned int begin, unsigned int end) {
    return query(root, 0, TOUR, begin, end);
  }
} T;
priority_queue<event> Q;
int poc[MAX], kraj[MAX];
int best[2 * MAX];
vector<int> E;
int Gpoz(int x) { return lower_bound(vremena, vremena + indvr, x) - vremena; }
void DodajVr(int x) {
  if (*lower_bound(vremena, vremena + indvr, x - 1) != x - 1)
    vremena[indvr++] = x - 1;
  if (*lower_bound(vremena, vremena + indvr, x) != x) vremena[indvr++] = x;
}
int main() {
  int n, r, rje = 0;
  scanf("%d%d", &n, &r);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &poc[i], &kraj[i]);
    poc[i] += MIL;
    kraj[i] += MIL;
    poc[i] = max(MIL, poc[i]);
    if (kraj[i] >= MIL) {
      E.push_back(poc[i]);
      E.push_back(kraj[i] + 1);
      Q.push(event{poc[i], i, -1});
      Q.push(event{kraj[i], i, 1});
      Q.push(event{poc[i], 0, 0});
    }
  }
  sort(E.begin(), E.end());
  vremena[0] = 0;
  indvr = 1;
  for (; !Q.empty();) {
    event tmp = Q.top();
    Q.pop();
    DodajVr(tmp.t);
    if (tmp.st == -1)
      T.insert(0, Gpoz(tmp.t), 1);
    else if (tmp.st == 1)
      T.insert(0, Gpoz(poc[tmp.ind]), -1);
    else {
      int val = T.query(0, Gpoz(tmp.t - r + 1));
      T.set(Gpoz(tmp.t), val);
      if ((long long)tmp.t + r < 2 * MIL) {
        int izmedu = lower_bound(E.begin(), E.end(), tmp.t) - E.begin();
        if (val > best[izmedu]) {
          best[izmedu] = val;
          if (val > tmp.ind) Q.push(event{tmp.t + r, val, 0});
        }
      }
      rje = max(rje, val);
    }
  }
  printf("%d\n", rje);
  return 0;
}