#include <bits/stdc++.h>
using namespace std;

using ll = long long;

void compress(vector<ll>& xs) {
    sort(xs.begin(), xs.end());
    xs.erase(unique(xs.begin(), xs.end()), xs.end());
}

int main() {
    ll n, L; cin >> n >> L;
    vector<ll> l(n), r(n);
    vector<ll> not_cover_cand, ps;
    for(int i = 0; i < n; ++i) {
        cin >> l[i] >> r[i];
        ps.push_back(l[i]);
        ps.push_back(r[i]);
        if(l[i] != 0) {
            not_cover_cand.push_back(l[i] - 1);
            ps.push_back(l[i] - 1);
        }
        if(r[i] != L) {
            not_cover_cand.push_back(r[i]);
        }
    }
    compress(ps);
    compress(not_cover_cand);

    const int m = ps.size();
    vector<ll> max_to(ps.size(), -1);
    for(int i = 0; i < n; ++i) {
        l[i] = lower_bound(ps.begin(), ps.end(), l[i]) - ps.begin();
        r[i] = lower_bound(ps.begin(), ps.end(), r[i]) - ps.begin();
        max_to[l[i]] = max(max_to[l[i]], r[i]);
    }
    for(int i = 0; i + 1 < m; ++i) {
        max_to[i + 1] = max(max_to[i + 1], max_to[i]);
    }

    int x = 0;
    for(ll i = 0, cur = 0; i < m && cur != m - 1; ++i) {
        x += 1;
        cur = max_to[cur];
    }

    vector<int> sum_l(m + 1), sum_r(m + 1);
    for(int i = 0; i < n; ++i) {
        sum_l[r[i]] += 1;
        if(l[i] != 0) {
            sum_r[l[i] - 1] += 1;
        }
    }
    for(int i = 0; i < m; ++i) {
        sum_l[i + 1] += sum_l[i];
    }
    for(int i = m - 1; i >= 0; --i) {
        sum_r[i] += sum_r[i + 1];
    }
    int y = 0;
    for(auto p : not_cover_cand) {
        p = lower_bound(ps.begin(), ps.end(), p) - ps.begin();
        //cout << ps[p] << " " << " -> " << sum_l[p] << " " << sum_r[p] << endl;
        y = max(y, sum_l[p] + sum_r[p]);
    }
    cout << x << " " << y + 1 << endl;
}

