#include<stdio.h>
#define TMAX 100000
int main(void){
	int N, T, time[TMAX], in, out, max=0, i, j;
	scanf("%d%d", &N, &T);
	for(j=0; j<=T; j++){
		*(time+j) = N;
	}
	for(i=0; i<N; i++){
		scanf("%d%d", &in, &out);
		if(0 != in || 100000 != out){
			for(j=0; j<in; j++){
				*(time+j) -= 1;
			}
			for(j=out; j<=T; j++){
				*(time+j) -= 1;
			}
		}
	}
	for(j=0; j<T; j++){
		max = (max < *(time+j) ? *(time+j) : max);
	}
	printf("%d\n", max);
	return 0;
}