#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
typedef long long ll;
const int N=4e5+10;
int n,ans2,cnt,now_r,b[N];ll L,t[N];
struct seg{ll l,r;}a[N];
int main(){
    scanf("%d%lld",&n,&L);
    rep(i,1,n) scanf("%lld%lld",&a[i].l,&a[i].r),t[++cnt]=a[i].l,t[++cnt]=a[i].r;
    sort(t+1,t+cnt+1);
    int w=unique(t+1,t+cnt+1)-t-1;
    rep(i,1,n) a[i].l=lower_bound(t+1,t+w+1,a[i].l)-t,a[i].r=lower_bound(t+1,t+w+1,a[i].r)-t,++b[a[i].l],--b[a[i].r];
    rep(i,1,w-1) b[i]+=b[i-1],ans2=max(ans2,n-b[i]);
    sort(a+1,a+n+1,[&](seg x,seg y){return x.l==y.l?x.r>y.r:x.l<y.l;});
    now_r=1;cnt=0;
    for(int i=1,j=1;i<=n;i=j){
        int tr=0;
        while(j<=n&&a[j].l<=now_r) tr=max(tr,(int)a[j].r),++j;
        now_r=tr;
        ++cnt;if(now_r==lower_bound(t+1,t+w+1,L)-t) break;
    }
    printf("%d %d\n",cnt,ans2+1);
    return 0;
}
