#include <bits/stdc++.h>
using namespace std;
int N, R;
bool used[400005];
vector<int> V[400005];
priority_queue<int, vector<int>, greater<int> > PQ;
int main() {
  scanf("%d%d", &N, &R);
  for (int i = 0; i < N; i++) {
    int l, r;
    scanf("%d%d", &l, &r);
    V[r].push_back(l + R);
  }
  int ans = N;
  for (int i = 1; i <= R * 2; i++) {
    if (i > R && used[i - R]) continue;
    for (int j = 0; j < V[i].size(); j++) PQ.push(V[i][j]);
    while (!PQ.empty() && PQ.top() < i) PQ.pop();
    if (!PQ.empty()) {
      PQ.pop();
      ans--;
      used[i] = 1;
    }
  }
  printf("%d\n", ans);
}
