#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

int N,K;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> N >> K;
    vector<int> memo(K+1),sum(K+1);
    REP(i,N){
        int l,r;
        cin >> l >> r;
        ++memo[l];--memo[r];
    }

    REP(i,K) sum[i+1] = sum[i] + memo[i];
    cout << *max_element(sum.begin(),sum.end()) << '\n';
    return 0;
}
