#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int inf = 1e9;
int mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  int L[n], R[n];
  for (int i = 0; i < n; i++) cin >> L[i] >> R[i];
  map<int, vector<int>> start, end;
  set<int> line;
  for (int i = 0; i < n; i++) {
    start[L[i]].push_back(i);
    end[R[i]].push_back(i);
    line.insert(L[i]);
    line.insert(R[i]);
  }
  set<int> s;
  int prev = 0;
  int dp[1 << 8];
  map<int, int> order[2 * n + 1];
  int cnt = 0;
  int ans = 0;
  memset(dp, 0, sizeof(dp));
  for (int cur : line) {
    for (int u : start[cur]) s.insert(u);
    cnt++;
    vector<int> val;
    int e = 0;
    for (int u : s) {
      order[cnt][u] = e++;
      val.push_back(u);
    }
    vector<int> temp(1 << 8, 0);
    for (int i = 0; i < (1 << (int)val.size()); i++) {
      int bit = 0;
      int y = 0, z = 0;
      for (int j = 0; j < (int)val.size(); j++) {
        if ((i >> j) & 1) {
          int x = val[j];
          if (order[cnt - 1].find(x) != order[cnt - 1].end()) {
            bit |= (1 << order[cnt - 1][x]);
            y ^= 1;
          }
          z ^= 1;
        }
      }
      temp[i] = dp[bit];
      temp[i] += y * (cur - prev - 1);
      temp[i] += z;
      ans = max(ans, temp[i]);
    }
    vector<int> f, b;
    for (int u : end[cur]) {
      b.push_back(u);
      s.erase(s.find(u));
    }
    for (int u : s) {
      f.push_back(u);
    }
    memset(dp, 0, sizeof(dp));
    for (int i = 0; i < (1 << (int)f.size()); i++) {
      int bit = 0;
      for (int k = 0; k < (int)f.size(); k++) {
        if ((i >> k) & 1) {
          bit |= (1 << order[cnt][f[k]]);
        }
      }
      int x = bit;
      for (int j = 0; j < (1 << (int)b.size()); j++) {
        bit = x;
        for (int k = 0; k < (int)b.size(); k++) {
          if ((j >> k) & 1) {
            bit |= (1 << order[cnt][b[k]]);
          }
        }
        dp[x] = max(dp[x], temp[bit]);
      }
    }
    prev = cur;
  }
  cout << ans << "\n";
  return 0;
}
