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;
struct Segtree {
  int l, r;
  int mx, lazy;
} tr[N * 16];
void build(int id, int l, int r) {
  tr[id].l = l;
  tr[id].r = r;
  tr[id].mx = tr[id].lazy = 0;
  if (l == r) return;
  int mid = (l + r) >> 1;
  build((id << 1), l, mid);
  build((id << 1 | 1), mid + 1, r);
}
inline void push_up(int id) {
  tr[id].mx = max(tr[(id << 1)].mx, tr[(id << 1 | 1)].mx);
}
inline void push_down(int id) {
  if (!tr[id].lazy) return;
  tr[(id << 1)].lazy += tr[id].lazy;
  tr[(id << 1 | 1)].lazy += tr[id].lazy;
  tr[(id << 1)].mx += tr[id].lazy;
  tr[(id << 1 | 1)].mx += tr[id].lazy;
  tr[id].lazy = 0;
}
void update(int id, int l, int r, int v) {
  if (tr[id].l == l && tr[id].r == r) {
    tr[id].mx += v;
    tr[id].lazy += v;
    return;
  }
  push_down(id);
  int mid = (tr[id].l + tr[id].r) >> 1;
  if (r <= mid)
    update((id << 1), l, r, v);
  else if (l > mid)
    update((id << 1 | 1), l, r, v);
  else {
    update((id << 1), l, mid, v);
    update((id << 1 | 1), mid + 1, r, v);
  }
  push_up(id);
}
int query(int id, int l, int r) {
  if (tr[id].l == l && tr[id].r == r) return tr[id].mx;
  push_down(id);
  int mid = (tr[id].l + tr[id].r) >> 1;
  if (r <= mid) return query((id << 1), l, r);
  if (l > mid) return query((id << 1 | 1), l, r);
  return max(query((id << 1), l, mid), query((id << 1 | 1), mid + 1, r));
}
int Inter[100], tc;
void get_int(int id, int l, int r) {
  if (tr[id].l == l && tr[id].r == r) {
    Inter[tc++] = id;
    return;
  }
  push_down(id);
  int mid = (tr[id].l + tr[id].r) >> 1;
  if (r <= mid)
    get_int((id << 1), l, r);
  else if (l > mid)
    get_int((id << 1 | 1), l, r);
  else {
    get_int((id << 1), l, mid);
    get_int((id << 1 | 1), mid + 1, r);
  }
}
map<int, int> mp;
int T, idx, pos[N * 4];
inline void add(int v) {
  mp[v] = ++idx;
  pos[idx] = v;
}
void solve(int id, int v, int lim) {
  if (tr[id].l == tr[id].r) {
    int x = pos[tr[id].l] + T;
    if (x >= lim) return;
    add(x);
    update(1, idx, idx, tr[id].mx);
    return;
  }
  push_down(id);
  if (tr[(id << 1)].mx > v) solve((id << 1), v, lim);
  v = max(v, tr[(id << 1)].mx);
  if (tr[(id << 1 | 1)].mx > v) solve((id << 1 | 1), v, lim);
}
int data[N * 3], cc;
pair<int, int> p[N];
int main() {
  int n, m = 0;
  scanf("%d%d", &n, &T);
  for (int i = 0; i < n; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    if (r < 0) continue;
    l = max(l, 0);
    p[m++] = make_pair(r + 1, l);
    data[cc++] = r + 1;
    data[cc++] = r;
    data[cc++] = l;
  }
  data[cc++] = 0x3f3f3f3f;
  sort(p, p + m);
  sort(data, data + cc);
  cc = unique(data, data + cc) - data;
  build(1, 1, 4 * n);
  idx = 0;
  for (int i = 0, j = 0; i < cc; ++i) {
    add(data[i]);
    for (; j < m && p[j].first <= data[i]; ++j) {
      update(1, mp[p[j].second], mp[p[j].first - 1], 1);
    }
    map<int, int>::iterator it = mp.upper_bound(data[i] - T);
    int v = 0;
    if (it != mp.begin()) {
      v = query(1, 1, (--it)->second);
      update(1, idx, idx, v);
      ++it;
    }
    if (i == cc - 1 || data[i] + 1 == data[i + 1] || it->second == idx)
      continue;
    tc = 0;
    get_int(1, it->second, idx - 1);
    for (int k = 0; k < tc; ++k) {
      int x = Inter[k];
      if (pos[tr[x].l] + T >= data[i + 1]) break;
      if (tr[x].mx <= v) continue;
      solve(x, v, data[i + 1]);
      v = tr[x].mx;
    }
  }
  printf("%d\n", tr[1].mx);
  return 0;
}