#include<vector>

template<typename T>
struct cumulative_sum {
    int n;
    T ZERO;
    std::vector<T> data;
    template<typename I> cumulative_sum(I begin, I end, T ZERO = T())
        : n(end - begin), ZERO(ZERO), data(n + 1) {
        std::copy(begin, end, data.begin() + 1);
        for (int i = 0; i < n; i++) { data[i + 1] += data[i]; }
    }
    T get_sum(int l, int r) const {
        if (l >= r || l > n || r < 0) { return ZERO; }
        if (l < 0) { l = 0; }
        if (r > n) { r = n; }
        return data[r] - data[l];
    }
};

#include<bits/stdc++.h>
using namespace std;

int main() {
    int N, T;
    cin >> N >> T;
    vector<int> v(T + 1);
    for (int i = 0; i < N; i++) {
        int l, r;
        cin >> l >> r;
        v[l]++, v[r]--;
    }
    cumulative_sum<int> cs(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i <= T; i++) { ans = max(ans, cs.get_sum(0, i)); }
    cout << ans << endl;
}
