#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 10;
vector<int> ls;
int n, m, k;
int a[maxn], b[maxn], len[maxn], bit[10];
int dp[500], odd[500];
int ans;
queue<int> que[maxn], que2[maxn];
void init() {
  for (int i = 1; i <= n; i++) ls.push_back(a[i]), ls.push_back(b[i] + 1);
  sort(ls.begin(), ls.end());
  ls.erase(unique(ls.begin(), ls.end()), ls.end());
  for (int i = 1; i < ls.size(); i++) len[i] = ls[i] - ls[i - 1];
  for (int i = 1; i <= n; i++)
    a[i] = upper_bound(ls.begin(), ls.end(), a[i]) - ls.begin(),
    b[i] = upper_bound(ls.begin(), ls.end(), b[i]) - ls.begin();
  m = ls.size() - 1;
  for (int i = 0; i < 256; i++) {
    int cnt = 0;
    for (int j = 0; j < 8; j++)
      if (i & (1 << j)) cnt++;
    if (cnt % 2) odd[i] = 1;
  }
}
void del(int x) {
  int pos;
  for (int i = 0; i < 10; i++)
    if (bit[i] == x) pos = i;
  bit[pos] = -1;
  for (int i = 0; i < 256; i++) {
    if (dp[i] == -1) continue;
    if (i & (1 << pos)) {
      dp[i] = -1;
      continue;
    }
    dp[i] = max(dp[i], dp[i | (1 << pos)]);
  }
}
void add(int x) {
  int pos;
  for (int i = 0; i < 10; i++)
    if (bit[i] == -1) {
      pos = i;
      break;
    }
  bit[pos] = x;
  for (int i = 255; i >= 0; i--) {
    if (i & (1 << pos)) {
      if (dp[i ^ (1 << pos)] != -1) dp[i] = dp[i ^ (1 << pos)];
    }
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) scanf("%d%d", &a[i], &b[i]);
  init();
  for (int i = 1; i <= n; i++) que[a[i]].push(i), que2[b[i] + 1].push(i);
  for (int i = 0; i < 500; i++) dp[i] = -1;
  for (int i = 0; i < 10; i++) bit[i] = -1;
  dp[0] = 0;
  int cur, tmp, pos;
  for (int i = 1; i <= m; i++) {
    while (que2[i].size()) {
      cur = que2[i].front();
      que2[i].pop();
      del(cur);
    }
    while (que[i].size()) {
      cur = que[i].front();
      que[i].pop();
      add(cur);
    }
    for (int j = 0; j < 256; j++)
      if (dp[j] != -1 && odd[j]) dp[j] += len[i];
    for (int j = 0; j < 256; j++) ans = max(ans, dp[j]);
  }
  printf("%d", ans);
  return 0;
}
