#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 998244353;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

ll N, L;
pl p[200000];
ll dp[400001];
ll sum[400001];
map<ll, int> rev;

int main() {
    cin >> N >> L;
    rep(i,N) cin >> p[i].first >> p[i].second;
    sort(p, p+N);
    set<ll> s;
    rep(i,N) { s.insert(p[i].first); s.insert(p[i].second); }
    {
        int i = 0;
        for (auto it = s.begin(); it != s.end(); it++) {
            rev[*it] = i++;
        }
    }
    rep(i,N) {
        p[i].first = rev[p[i].first];
        p[i].second = rev[p[i].second];
    }
    dp[0] = 0;
    int st = 0;
    int ans = 0;
    ll last = 0;
    while (true) {
        ll M = 0;
        for (; st < N; st++) {
            if (p[st].first > last) break;
            M = max(M, p[st].second);
        }
        ans++;
        last = M;
        if (st == N) break;
        if (last+1 == s.size()) break;
    }
    rep(i,N) {
        sum[p[i].first]++;
        sum[p[i].second+1]--;
    }
    ll ans2 = sum[0];
    for (int i = 1; i < s.size(); i++) {
        sum[i] += sum[i-1];
        ans2 = min(ans2, sum[i]);
    }
    cout << ans << " " << N-ans2+1 << endl;
}
