#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define int long long
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef pair<int, int> P;

int N, L;
P pl[200000];	//l昇順, (l, r)
P pr[200000];	//r昇順, (r, l)

int calcX() {
	int i = 0;
	int left = 0;
	int ret = 0;
	
	while (i < N) {
		int maxR = left;
		for (; i < N && pl[i].first <= left; i++) {
			maxR = max(maxR, pl[i].second);
		}
		left = maxR;
		ret++;
		if (maxR == L) break;
	}
	return ret;
}

int calcY() {
	int i;
	vector<int> xs;
	
	rep(i, N) {
		xs.push_back(pl[i].first);
		xs.push_back(pl[i].second);
	}
	sort(xs.begin(), xs.end());
	xs.erase(unique(xs.begin(), xs.end()), xs.end());
	
	/*cout << "pl[]" << endl;
	rep(i, N) {
		cout << pl[i].first << ", " << pl[i].second << endl;
	}
	cout << endl;
	cout << "pr[]" << endl;
	rep(i, N) {
		cout << pr[i].first << ", " << pr[i].second << endl;
	}*/
	
	int ret = 0;
	rep(i, xs.size()) {
		//r < x
		int idL = lower_bound(pr, pr + N, P(xs[i], -1)) - pr;
		int cntL = idL;
		//l > x
		int idR = lower_bound(pl, pl + N, P(xs[i] + 1, -1)) - pl;
		int cntR = N - idR;
		ret = max(ret, cntL + cntR);
		//cout << "x = " << xs[i] << ", cntL = " << cntL << ", cntR = " << cntR << endl;
	}
	return ret + 1;
}

signed main() {
	int i;
	
	cin >> N >> L;
	rep(i, N) {
		int l, r;
		cin >> l >> r;
		pl[i] = P(l, r);
		pr[i] = P(r, l);
	}
	sort(pl, pl + N);
	sort(pr, pr + N);
	
	int x = calcX();
	int y = calcY();
	cout << x << " " << y << endl;
	return 0;
}
