import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

void main() {
    auto s = readln.split.map!(to!long);
    auto N = s[0].to!int;
    auto L = s[1];
    auto A = N.iota.map!(_ => readln.split.map!(to!long).array).array;
    A.sort!"a[0] < b[0]";

    {
        auto pq = new BinaryHeap!(Array!long, "a < b");
        long right = 0;
        int p = 0;
        int ans = 0;
        while (right < L) {
            while (p < N && A[p][0] <= right) {
                pq.insert(A[p][1]);
                p += 1;
            }
            right = pq.front;
            pq.removeFront;
            ans += 1;
        }
        write(ans, " ");
    }

    {
        long[] B;
        foreach (a; A) B ~= a;
        B = B.sort().uniq.array;
        long[long] comp;
        foreach (i; 0..B.length.to!int) comp[B[i]] = i;
        foreach (i; 0..N) A[i][0] = comp[A[i][0]], A[i][1] = comp[A[i][1]];
        L = B.length.to!long - 1;

        auto imos = new int[](L+1);
        foreach (i; 0..N) {
            imos[A[i][0]] += 1;
            imos[A[i][1]] -= 1;
        }
        foreach (i; 0..L) {
            imos[i+1] += imos[i];
        }
        int ans = 1;
        foreach (i; 0..L) {
            ans = max(ans, N - imos[i] + 1);
        }
        ans.writeln;
    }
}

