#include <bits/stdc++.h>
short arre[100005];
long long maxi = INT_MIN, n, s, t;
using namespace std;
int main() {
  cin >> n >> t;
  int a, b;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    arre[a]++;
    arre[b]--;
  }
  for (int i = 0; i <= t; i++) {
    s += arre[i];
    if (s > maxi) maxi = s;
  }
  cout << maxi << "\n";
  return 0;
}
