#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int N, T; cin >> N >> T;
	vector<int> p(T+1, 0);
	for (int i = 0; i < N;i++) {
		int l, r; cin >> l >> r;
		p[l]++; p[r]--;
	}
	int Ans = 0;
	int Sum = 0;
	for (int t : p) {
		Sum += t;
		Ans = max(Ans, Sum);
	}
	cout << Ans << endl;
}