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 tope = 1 << 20;
const int primero = 1 << 19;
int maximo[tope], anyade[tope];
void inserta(int pos, int val) {
  pos += primero;
  maximo[pos] = val;
  while (pos > 1) {
    pos /= 2;
    maximo[pos] = max(maximo[2 * pos] + anyade[2 * pos],
                      maximo[2 * pos + 1] + anyade[2 * pos + 1]);
  }
}
void acumula(int pos0, int pos1) {
  if (pos0 > pos1) return;
  pos0 += primero;
  pos1 += primero;
  if (pos0 == pos1) {
    anyade[pos0]++;
  } else {
    anyade[pos0]++;
    anyade[pos1]++;
    while (pos0 + 1 < pos1) {
      if (pos0 % 2 == 0) anyade[pos0 + 1]++;
      pos0 /= 2;
      maximo[pos0] = max(maximo[2 * pos0] + anyade[2 * pos0],
                         maximo[2 * pos0 + 1] + anyade[2 * pos0 + 1]);
      if (pos1 % 2 == 1) anyade[pos1 - 1]++;
      pos1 /= 2;
      maximo[pos1] = max(maximo[2 * pos1] + anyade[2 * pos1],
                         maximo[2 * pos1 + 1] + anyade[2 * pos1 + 1]);
    }
  }
  int pos = pos0;
  while (pos > 1) {
    pos /= 2;
    maximo[pos] = max(maximo[2 * pos] + anyade[2 * pos],
                      maximo[2 * pos + 1] + anyade[2 * pos + 1]);
  }
}
int obtenmaximo(int pos) {
  pos += primero;
  int m = maximo[pos] + anyade[pos];
  while (pos > 1) {
    if (pos % 2 == 1) m = max(m, maximo[pos - 1] + anyade[pos - 1]);
    pos /= 2;
    m += anyade[pos];
  }
  return m;
}
struct elem {
  int entran;
  vector<int> salen;
  elem() { entran = 0; }
};
map<int, elem> mapa;
int n, r;
vector<pair<int, int> > lista;
int ilista = 0;
void insertalista(int tiempodisparo, int patosmatados, int patosmatadosantes) {
  if (lista.back().second >= patosmatados) return;
  inserta(int(lista.size()), patosmatadosantes);
  lista.push_back(pair<int, int>(tiempodisparo, patosmatados));
  mapa[tiempodisparo + r];
}
int obtenposicion(int t) {
  int inf = -1;
  int sup = int(lista.size());
  while (inf + 1 < sup) {
    int med = (inf + sup) / 2;
    if (lista[med].first < t)
      inf = med;
    else
      sup = med;
  }
  return sup;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> r;
  for (int i = 0; i < n; i++) {
    int h, t;
    cin >> h >> t;
    if (t < 0) continue;
    h = max(h, 0);
    mapa[h].entran++;
    mapa[t].salen.push_back(h);
    mapa[t + 1];
  }
  lista.push_back(pair<int, int>(-2000000005, 0));
  int patosactivos = 0;
  int sol = 0;
  for (map<int, elem>::iterator it = mapa.begin(); it != mapa.end(); it++) {
    int tiempo = it->first;
    patosactivos += it->second.entran;
    vector<int> &salen = it->second.salen;
    while (ilista < int(lista.size()) - 1 and
           lista[ilista + 1].first + r <= tiempo)
      ilista++;
    int patosmatadosantes = obtenmaximo(ilista);
    int patosmatados = patosmatadosantes + patosactivos;
    sol = max(sol, patosmatados);
    insertalista(tiempo, patosmatados, patosmatadosantes);
    for (int i = 0; i < int(salen.size()); i++) {
      int t = salen[i];
      int p = obtenposicion(t);
      acumula(p, int(lista.size()) - 1);
      patosactivos--;
    }
  }
  cout << sol << endl;
}