#include <stdio.h>          // printf(), scanf()
#define MAX_T 100000

int
main(int argc, char** argv)
{
	int t[MAX_T + 1];
	int n, T;
	int l, r;
	int i;

	scanf("%d %d", &n, &T);
	for (i = 0; i <= T; ++i)
		t[i] = 0;

	for (i = 0; i < n; ++i)
	{
		scanf("%d %d", &l, &r);
		t[l]++;
		t[r]--;
	}

	int max = 0;
	int acc = 0;
	for (i = 0; i <= T; ++i)
	{
		acc += t[i];
		if (acc > max)
			max = acc;
	}

	printf("%d\n", max);
	return 0;
}