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