#include <bits/stdc++.h>
#pragma GCC optimize("-O3")
using namespace std;
void _main();
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  _main();
}
int N, M, L[201010], R[201010];
int solveO2N() {
  int ans = 0;
  for (int mask = 1; mask < 1 << N; mask++) {
    int LL = -1, RR = M + 2, human = 0;
    for (int i = 0; i < N; i++)
      if (mask & (1 << i)) {
        LL = max(LL, L[i]);
        RR = min(RR, R[i]);
        human++;
      }
    int chair = -1;
    if (RR <= LL)
      chair = M;
    else
      chair = LL + (M + 1 - RR);
    ans = max(ans, human - chair);
  }
  return ans;
}
void _main() {
  cin >> N >> M;
  for (int i = 0; i < N; i++) cin >> L[i] >> R[i];
  if (N < 20) return;
  cout << solveO2N() << endl;
}
