#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000050;
int N, M, match;
pair<pair<int, int>, int> P[MAXN];
vector<pair<pair<int, int>, int>> v;
bitset<MAXN> done;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>>
    pq;
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  return a.first.first + a.first.second < b.first.first + b.first.second;
}
int main() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; ++i) {
    scanf("%d%d", &P[i].first.first, &P[i].first.second);
  }
  sort(P, P + N, cmp);
  for (int i = 0; i < N; ++i) {
    v.emplace_back(make_pair(0, P[i].first.first), i);
    v.emplace_back(make_pair(P[i].first.second, M), i);
  }
  sort(v.begin(), v.end());
  for (int i = 1, it = 0; i <= M; ++i) {
    while (it < v.size()) {
      if (v[it].first.first <= i) {
        pq.push(pair<int, int>(-v[it].second, v[it].first.second));
        ++it;
      } else
        break;
    }
    while (!pq.empty()) {
      auto cur = pq.top();
      pq.pop();
      cur.first = -cur.first;
      if (done[cur.first]) continue;
      if (cur.second < i) continue;
      done[cur.first] = 1;
      ++match;
      break;
    }
  }
  printf("%d\n", N - match);
}
