#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,L,x=0,y=LINF;cin>>N>>L;
  std::vector<int> v(2*N+5,0),used(2*N+5,0);
  typedef pair<int,int> P;
  std::vector<P> lr(N+1);
  map<int,int> m;
  for(int i=0;i<N;i++){
    int l,r;cin>>l>>r;m[l]=m[r]=0;
    lr[i]=P(l,r);
  }
  int cnt=0;
  for(auto &p:m)p.second=cnt++;
  for(int i=0;i<N;i++)lr[i]=P(m[lr[i].first],m[lr[i].second]);
  L=m[L];
  lr[N]=P(LINF,LINF);
  sort(lr.begin(),lr.end());
  int nownum=0,nowpo=0;
  priority_queue<int> que;
  while(nowpo<L){
    while(lr[nownum].first<=nowpo)que.push(lr[nownum++].second);
    nowpo=que.top();que.pop();
    x++;
  }
  for(int i=0;i<N;i++)v[lr[i].first]++,v[lr[i].second]--;
  for(int i=0;i<L+4;i++)v[i+1]+=v[i];
  for(int i=0;i<L;i++)y=min(y,v[i]);
  cout<<x<<" "<<N-y+1<<endl;
}

