/*  -*- coding: utf-8 -*-
 *
 * 2969.cc: Universal and Existential Quantifiers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_M = MAX_N * 2;
const int MAX_E2 = 1 << 20; // = 1048576
const int INF = 1 << 30;

/* typedef */

typedef long long ll;
typedef vector<int> vi;

template <typename T, const int MAX_E2>
struct SegTreeMin {
  int n, e2;
  T nodes[MAX_E2], def;
  SegTreeMin() {}

  void init(int _n, T _def) {
    n = _n; def = _def;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(nodes, nodes + MAX_E2, def);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;
    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = min<T>(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }

  T min_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return def;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = min_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = min_range(r0, r1, k * 2 + 2, im, i1);
    return min<T>(v0, v1);
  }
  T min_range(int r0, int r1) { return min_range(r0, r1, 0, 0, e2); }
};

/* global variables */

ll ls[MAX_N], rs[MAX_N], xs[MAX_M];
vi nbrs[MAX_M];
SegTreeMin<int,MAX_E2> st;
int cs[MAX_M];

/* subroutines */

/* main */

int main() {
  int n;
  ll l;
  scanf("%d%lld", &n, &l);

  for (int i = 0, j = 0; i < n; i++) {
    scanf("%lld%lld", ls + i, rs + i);
    xs[j++] = ls[i];
    xs[j++] = rs[i];
  }

  sort(xs, xs + n * 2);
  int m = unique(xs, xs + n * 2) - xs;
  //printf("m=%d\n", m);

  for (int i = 0; i < n; i++) {
    int li = lower_bound(xs, xs + m, ls[i]) - xs;
    int ri = lower_bound(xs, xs + m, rs[i]) - xs;
    nbrs[li].push_back(ri);
    cs[li]++, cs[ri]--;
  }

  st.init(m, INF);
  st.set(0, 0);

  for (int i = 0; i < m; i++)
    if (! nbrs[i].empty()) {
      int d = st.min_range(i, m) + 1;
      vi &nbri = nbrs[i];
      for (vi::iterator vit = nbri.begin(); vit != nbri.end(); vit++) {
	int &j = *vit;
	if (st.get(j) > d) st.set(j, d);
      }
    }

  int minc = cs[0];
  for (int i = 1; i < m - 1; i++) {
    cs[i] += cs[i - 1];
    if (minc > cs[i]) minc = cs[i];
  }

  printf("%d %d\n", st.get(m - 1), n - (minc - 1));
  return 0;
}

