#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main(){
  long long N, L;
  cin >> N >> L;
  map<long long, long long> M;
  M[L] = 1;
  vector<pair<long long,long long>> V;
  for(long long i = 0; i < N; ++i){
    long long l, r;
    cin >> l >> r;
    M[l] = 1;
    M[r] = 1;
    V.emplace_back(l,r);
  }
  long long n = 0;
  for(auto &p : M){
    p.second = n++;
  }
  L = M[L];
  vector<long long> I(L+1,0);
  vector<pair<long long,long long>> T;
  for(long long i = 0; i < N; ++i){
    V[i].first = M[V[i].first];
    V[i].second = M[V[i].second];
    ++I[V[i].first];
    --I[V[i].second];
    T.emplace_back(V[i].first,-V[i].second);
  }
  sort(T.begin(),T.end());
  long long r = 0, x = 0, j = 0;
  while(r < L){
    long long nex_r = r;
    for(;j < N and T[j].first <= r; ++j){
      nex_r = max(nex_r,-T[j].second);
    }
    r = nex_r;
    ++x;
  }
  long long t = N;
  for(long long i = 1; i <= L; ++i){
    I[i] += I[i-1];
    t = min(t,I[i-1]);
  }
  long long y = N - t + 1;
  cout << x << " " << y << endl;
}

