#include <bits/stdc++.h>
using namespace std;
int N, M, K;
int pos[200005], p_pos;
int start[200005];
int finish[200005];
bool active[10];
int id[200005];
pair<int, int> seg[200005];
int p_seg;
int memo[200005][260];
void add_segment(int num) {
  for (int i = 0; i < 8; i++) {
    if (active[i] == 0) {
      id[num] = i;
      break;
    }
  }
  active[id[num]] = 1;
  start[p_pos] = id[num];
}
void delete_segment(int num) {
  num = -num;
  active[id[num]] = 0;
  finish[p_pos] = id[num];
  start[p_pos] = -1;
}
bool valid(int mask) { return __builtin_popcount(mask) & 1; }
int dp(int idx, int mask) {
  if (idx == N + N) return valid(mask) ? pos[idx] - pos[idx - 1] : 0;
  if (memo[idx][mask] != -1) return memo[idx][mask];
  int res = 0;
  if (start[idx] != -1) {
    res = max(res, dp(idx + 1, mask));
    res = max(res, dp(idx + 1, mask | (1 << start[idx])));
  } else {
    res = dp(idx + 1, mask & ~(1 << finish[idx]));
  }
  return memo[idx][mask] = res + (valid(mask) ? pos[idx] - pos[idx - 1] : 0);
}
int main() {
  memset(memo, -1, sizeof(memo));
  ios_base::sync_with_stdio(0);
  cin >> N >> M >> K;
  int l, r;
  for (int i = 1; i <= N; i++) {
    cin >> l >> r;
    seg[++p_seg] = {l, i};
    seg[++p_seg] = {r + 1, -i};
  }
  sort(seg + 1, seg + N + N + 1);
  for (int i = 1; i <= N + N; i++) {
    pos[++p_pos] = seg[i].first;
    if (seg[i].second > 0) {
      add_segment(seg[i].second);
    } else {
      delete_segment(seg[i].second);
    }
  }
  cout << dp(1, 0) << "\n";
}
