#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
#define fi first
#define sec second
#define INF 1000000000
const int SIZE = 1<<20;
struct segtree{
	int seg[SIZE*2];
	segtree(){
		for(int i=0;i<SIZE*2;i++){
			seg[i] = INF;
		}
	}
	void update(int k,int x){
		k += SIZE-1;
		seg[k] = min(seg[k],x);
		while(k>0){
			k = (k-1)/2;
			seg[k] = min(seg[k*2+1],seg[k*2+2]);
		}
	}
	int query(int a,int b,int k,int l,int r){
		if(r<=a||b<=l)return INF;
		if(a<=l&&r<=b)return seg[k];
		int mid = (l+r)/2;
		return min(query(a,b,k*2+1,l,mid),query(a,b,k*2+2,mid,r));
	}
}seg;
bool comp(P a,P b){
	if(a.sec!=b.sec)return a.sec < b.sec;
	else return a.fi < b.fi;
}
int N;
ll L;
vector<ll> zip;
vector<P> vec;
int dp[400100];
int rui[400100];
int main(){
	cin >> N >> L;
	zip.pb(L);
	vec.resize(N);
	for(int i=0;i<N;i++){
		cin >> vec[i].fi >> vec[i].sec;
		zip.pb(vec[i].fi);
		zip.pb(vec[i].sec);
	}
	zip.pb(0ll);
	sort(zip.begin(),zip.end());
	zip.erase(unique(zip.begin(),zip.end()),zip.end());
	for(int i=0;i<N;i++){
		vec[i].fi = lower_bound(zip.begin(),zip.end(),vec[i].fi)-zip.begin();
		vec[i].sec = lower_bound(zip.begin(),zip.end(),vec[i].sec)-zip.begin();
		rui[vec[i].fi]++;
		rui[vec[i].sec]--;
	}
	sort(vec.begin(),vec.end(),comp);
	// for(int i=0;i<vec.size();i++){
	// 	cout << vec[i].fi << ' ' << vec[i].sec << endl;
	// }
	for(int i=1;i<=zip.size();i++){
		dp[i] = INF;
	}
	dp[0] = 0ll;
	seg.update(0,dp[0]);
	for(int i=0;i<vec.size();i++){
		int l = vec[i].fi;
		int r = vec[i].sec;
		dp[r] = min(dp[r],seg.query(l,r,0,0,SIZE)+1);
		seg.update(r,dp[r]);
	}
	for(int i=1;i<zip.size();i++){
		rui[i] += rui[i-1];
	}
	int mi = INF;
	for(int i=0;i+1<zip.size();i++){
		mi = min(mi,rui[i]);
	}
	cout << dp[zip.size()-1] << ' ' << N-mi+1 << endl;
	return 0;
}


