#include <string>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1000000000000000000

using namespace std;

struct SegTree{
	int size;
	vector<llint> seg;
	
	SegTree(){}
	SegTree(int size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	void init()
	{
		for(int i = 0; i < (1<<(size+1)); i++) seg[i] = inf;
	}
	void update(int i, llint val)
	{
		i += (1<<size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = min(seg[i*2], seg[i*2+1]);
		}
	}
	llint query(int a, int b, int k, int l, int r)
	{
		if(b < l || r < a) return inf;
		if(a <= l && r <= b) return seg[k];
		llint lval = query(a, b, k*2, l, (l+r)/2);
		llint rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return min(lval, rval);
	}
	llint query(int a, int b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint n, L;
llint l[200005], r[200005];
vector<llint> comp;
llint dp[400005];
llint dif[400005], sum[400005];
vector<llint> vec[400005];
SegTree seg(19);

int main(void)
{
	cin >> n >> L;
	for(int i = 1; i <= n; i++) cin >> l[i] >> r[i];
	
	for(int i = 1; i <= n; i++) comp.push_back(l[i]), comp.push_back(r[i]);
	sort(comp.begin(), comp.end());
	comp.erase(unique(comp.begin(), comp.end()), comp.end());
	for(int i = 1; i <= n; i++) l[i] = lower_bound(comp.begin(), comp.end(), l[i]) - comp.begin() + 1;
	for(int i = 1; i <= n; i++) r[i] = lower_bound(comp.begin(), comp.end(), r[i]) - comp.begin() + 1;
	for(int i = 1; i <= n; i++) vec[r[i]].push_back(l[i]);
	
	llint m = comp.size();
	//cout << m << endl;
	
	//for(int i = 1; i <= n; i++) cout << l[i] << " " << r[i] << endl;
	
	seg.init();
	seg.update(1, 0);
	for(int i = 2; i <= m; i++){
		llint mn = inf;
		for(int j = 0; j < vec[i].size(); j++){
			mn = min(mn, seg.query(vec[i][j], i-1));
		}
		seg.update(i, mn+1);
	}
	llint ansx = seg.query(m, m);
	
	for(int i = 1; i <= n; i++){
		dif[l[i]]++, dif[r[i]]--;
	}
	llint ansy = inf;
	for(int i = 1; i < m; i++){
		sum[i] = sum[i-1] + dif[i];
		ansy = min(ansy, sum[i]);
	}
	//cout << ansy << endl;
	ansy = n - ansy + 1;
	
	cout << ansx << " " << ansy << endl;
	
	return 0;
}
