#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, m;
pair<int, int> a[N];
bool cmp(pair<int, int> x, pair<int, int> y) {
  if (x.first - x.second != y.first - x.second)
    return x.first - x.second < y.first - y.second;
  return x.first < y.first;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d%d", &a[i].first, &a[i].second);
  sort(a, a + n, cmp);
  int lf = 0, ri = m + 1, ans = 0;
  for (int i = 0; i < n; i++)
    if (a[i].first > lf)
      ++lf, ++ans;
    else if (a[i].second < ri)
      --ri, ++ans;
  printf("%d\n", n - ans);
  return 0;
}
