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 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;
};
int vremena[10 * MAX], indvr;
struct tour {
  node t[2 * TOUR];
  void propagiraj(int p) {
    for (int i = 2 * p; i <= 2 * p + 1; i++) {
      t[i].maxx += t[p].prop;
      t[i].prop += t[p].prop;
    }
    t[p].prop = 0;
  }
  void set(int pos, int lo, int hi, int gdje, int val) {
    if (lo >= gdje + 1 || hi <= gdje) return;
    if (lo == gdje && hi == gdje + 1) {
      t[pos].maxx = max(t[pos].maxx, val);
      return;
    }
    propagiraj(pos);
    set(2 * pos + 0, lo, (lo + hi) / 2, gdje, val);
    set(2 * pos + 1, (lo + hi) / 2, hi, gdje, val);
    t[pos].maxx = max(t[2 * pos + 0].maxx, t[2 * pos + 1].maxx);
  }
  void set(int gdje, int val) { set(1, 0, TOUR, gdje, val); }
  void insert(int pos, int lo, int hi, int begin, int end, int val) {
    if (lo >= end || hi <= begin) return;
    if (lo >= begin && hi <= end) {
      t[pos].maxx += val;
      t[pos].prop += val;
      return;
    }
    propagiraj(pos);
    insert(2 * pos + 0, lo, (lo + hi) / 2, begin, end, val);
    insert(2 * pos + 1, (lo + hi) / 2, hi, begin, end, val);
    t[pos].maxx = max(t[2 * pos + 0].maxx, t[2 * pos + 1].maxx);
  }
  void insert(int begin, int end, int val) {
    insert(1, 0, TOUR, begin, end, val);
  }
  int query(int pos, int lo, int hi, int begin, int end) {
    if (lo >= end || hi <= begin) return 0;
    if (lo >= begin && hi <= end) return t[pos].maxx;
    propagiraj(pos);
    return max(query(2 * pos + 0, lo, (lo + hi) / 2, begin, end),
               query(2 * pos + 1, (lo + hi) / 2, hi, begin, end));
  }
  int query(int begin, int end) { return query(1, 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;
}