#include<bits/stdc++.h>
using namespace std;

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) v.begin(),v.end()
using vint=vector<int>;

int N,L;

vector<int>lis[444444];
int acc[444444];
signed  main(){
  cin>>N>>L;
  vector<int> l(N),r(N);
  for(int i=0;i<N;i++)cin>>l[i]>>r[i];
  
   
  vector<int>vs;
  vs.push_back(0);vs.push_back(L);for(int i=0;i<N;i++)vs.push_back(l[i]),vs.push_back(r[i]);
  sort(vs.begin(),vs.end());vs.erase(unique(vs.begin(),vs.end()),vs.end());
  L=lower_bound(vs.begin(),vs.end(),L)-vs.begin();
  for(int i=0;i<N;i++){
    l[i]=lower_bound(vs.begin(),vs.end(),l[i])-vs.begin();
    r[i]=lower_bound(vs.begin(),vs.end(),r[i])-vs.begin();
  }

  rep(i,N)lis[l[i]].pb(r[i]);

  int cur=0;
  int v=0;
  int ans=0;
  while(v!=L){
    int vv=0;
    while(cur<=v){
      for(auto a:lis[cur])vv=max(vv,a);
      cur++;
    }
    v=vv;
    ans++;
  }
  cout<<ans<<" ";
  rep(i,N)acc[l[i]]++,acc[r[i]]--;
  
  ans=0;
  rep(i,vs.size()-1){
    acc[i+1]+=acc[i];
    ans=max(ans,N-acc[i]+1);
  }
  cout<<ans<<endl;
}

