#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { cin.tie(nullptr)->sync_with_stdio(false); int n, h; cin >> n >> h; vector sum(h + 1); rep(_, n) { int a, b; cin >> a >> b; sum[a]++, sum[b + 1]--; } rep(i, h) sum[i + 1] += sum[i]; int ans = 0; rep(i, h + 1) ans = max(ans, sum[i]); cout << ans << '\n'; return 0; }