#include <bits/stdc++.h>
using namespace std;
inline void chkmax(long long &a, long long b) {
  if (a < b) a = b;
}
inline void chkmin(long long &a, long long b) {
  if (a > b) a = b;
}
inline long long read() {
  long long a = 0, fh = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') fh = -1;
    c = getchar();
  }
  while ('0' <= c && c <= '9') {
    a = a * 10 + c - 48;
    c = getchar();
  }
  return a * fh;
}
long long n, m, K, N;
vector<long long> id[500005], st[500005];
long long pos[9], belong[9];
pair<long long, long long> q[500005];
long long MAX[1 << 9], f[2][1 << 9], op[1 << 9], v[500005];
signed main() {
  n = read();
  m = read();
  K = read();
  for (long long i = 1; i <= n; ++i) {
    v[++N] = q[i].first = read() - 1;
    v[++N] = q[i].second = read();
  }
  sort(v + 1, v + 1 + N);
  N = unique(v + 1, v + 1 + N) - v - 1;
  for (long long i = 1; i <= n; ++i) {
    q[i].first = lower_bound(v + 1, v + 1 + N, q[i].first) - v;
    q[i].second = lower_bound(v + 1, v + 1 + N, q[i].second) - v;
    for (long long j = q[i].first + 1; j <= q[i].second; ++j) {
      id[j].push_back(i);
    }
    st[q[i].first + 1].push_back(i);
  }
  f[1][0] = 0;
  op[0] = 0;
  for (long long i = 1; i < (1 << 8); ++i)
    for (long long j = 0; j < 8; ++j)
      if ((i >> j) & 1) op[i] = op[i ^ (1 << j)] ^ 1;
  for (long long i = 2; i <= N; ++i) {
    memset(MAX, -0x3f, sizeof(MAX));
    for (long long j = 0; j < id[i - 1].size(); ++j) {
      belong[j] = -1;
      for (long long k = 0; k < id[i].size(); ++k)
        if (id[i - 1][j] == id[i][k]) {
          belong[j] = k;
          break;
        }
    }
    for (long long j = 0; j < st[i].size(); ++j) {
      pos[j] = -1;
      for (long long k = 0; k < id[i].size(); ++k)
        if (st[i][j] == id[i][k]) {
          pos[j] = k;
          break;
        }
    }
    long long cnt = id[i - 1].size();
    for (long long j = 0; j < (1 << cnt); ++j) {
      long long ST = 0;
      for (long long k = 0; k < cnt; ++k)
        if (((j >> k) & 1) && belong[k] != -1) ST |= (1 << belong[k]);
      chkmax(MAX[ST], f[(i - 1) & 1][j]);
    }
    long long tot = id[i].size(), tmp = st[i].size();
    for (long long j = 0; j < (1 << tot); ++j) {
      if (MAX[j] < 0) continue;
      for (long long k = 0; k < (1 << tmp); ++k) {
        long long ST = j;
        for (long long l = 0; l < tmp; ++l)
          if (k & (1 << l)) ST ^= (1 << pos[l]);
        chkmax(f[i & 1][ST], MAX[j] + op[ST] * (v[i] - v[i - 1]));
      }
    }
    memset(f[(i - 1) & 1], -0x3f, sizeof(f[(i - 1) & 1]));
  }
  long long ans = 0;
  for (long long i = 0; i < (1 << 8); ++i) chkmax(ans, f[N & 1][i]);
  printf("%d\n", ans);
  return 0;
}
