#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int first = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
  while (isdigit(ch)) first = first * 10 + (ch ^ 48), ch = getchar();
  return (f) ? -first : first;
}
const int N = 2e5 + 5;
const int M = (1 << 8) + 5;
int n, m, mx, f[N][M], l[N], r[N], tmp[N], g[M], gs, ans;
vector<int> yzc[N];
inline int calc(int first) {
  int gs = 0;
  for (int i = (1); i <= (8); i++)
    if (first & (1 << i - 1)) gs++;
  return gs;
}
int main() {
  n = read(), m = read(), mx = read();
  for (int i = (1); i <= (n); i++) {
    l[i] = read(), r[i] = read() + 1;
    tmp[++gs] = l[i], tmp[++gs] = r[i];
  }
  sort(tmp + 1, tmp + gs + 1);
  gs = unique(tmp + 1, tmp + gs + 1) - tmp - 1;
  for (int i = (1); i <= (n); i++) {
    l[i] = lower_bound(tmp + 1, tmp + gs + 1, l[i]) - tmp;
    r[i] = lower_bound(tmp + 1, tmp + gs + 1, r[i]) - tmp;
    for (int j = (l[i]); j <= (r[i] - 1); j++) yzc[j].push_back(i);
  }
  for (int i = (1); i <= (gs - 1); i++) {
    int la = tmp[i], now = tmp[i + 1];
    int len = now - la;
    vector<int> L, R;
    L.clear(), R.clear();
    int Sz1 = (int)yzc[i - 1].size() - 1;
    int Sz2 = (int)yzc[i].size() - 1;
    for (int j = (0); j <= (Sz1); j++)
      for (int k = (0); k <= (Sz2); k++)
        if (yzc[i - 1][j] == yzc[i][k]) L.push_back(j), R.push_back(k);
    Sz1 = (int)L.size(), Sz2 = (int)R.size();
    int Ms = (1 << (int)yzc[i - 1].size()) - 1;
    memset(g, 0, sizeof g);
    for (int S = (0); S <= (Ms); S++) {
      int NS = 0;
      for (int j = (0); j <= (Sz1 - 1); j++)
        if ((S >> L[j]) & 1) NS |= (1 << j);
      g[NS] = max(g[NS], f[i - 1][S]);
    }
    Ms = (1 << (int)yzc[i].size()) - 1;
    for (int S = (0); S <= (Ms); S++) {
      int NS = 0;
      for (int j = (0); j <= (Sz2 - 1); j++)
        if ((S >> R[j]) & 1) NS |= (1 << j);
      int gs = calc(S);
      f[i][S] = max(f[i][S], g[NS] + (gs & 1) * len);
      ans = max(ans, f[i][S]);
    }
  }
  printf("%d\n", ans);
  return 0;
}
