#include<bits/stdc++.h>
#define MAX 100010
#define inf 1<<29
#define linf 1e18
#define eps (1e-10)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int n,t,ans=0,sum=0;
int T[MAX]={};

int main()
{
  cin>>n>>t;
  FOR(i,0,n){
    int l,r;
    cin>>l>>r;
    T[l]++;
    T[r]--;
  }
  FOR(i,0,t+1){
    sum+=T[i];
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
    
  return 0;
}