#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long inf = 1LL << 50;
const int N = 100000;
pair<int, int> vals[N * 2 + 5];
int spell[N][2];
int dp[2 * N + 5][256];
int inserts[2 * N + 5];
vector<int> spells[2 * N + 5];
vector<pair<int, int> > srted(2 * N);
int comp(pair<int, int>& a, pair<int, int>& b) {
  if (spell[a.first][a.second] < spell[b.first][b.second]) {
    return 1;
  }
  if (spell[a.first][a.second] > spell[b.first][b.second]) {
    return 0;
  }
  return a.second < b.second;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin.exceptions(cin.failbit);
  int n, m, k;
  cin >> n >> m >> k;
  fill(&dp[0][0], &dp[0][0] + 2 * N * 256, -1);
  for (int i = 0; i < n; i++) {
    cin >> spell[i][0] >> spell[i][1];
    srted[i * 2] = {i, 0};
    srted[i * 2 + 1] = {i, 1};
  }
  sort(srted.begin(), srted.begin() + 2 * n, comp);
  int last = spell[srted[0].first][0];
  set<int> q;
  q.insert(srted[0].first);
  for (int i = 1; i < 2 * n; i++) {
    if (!srted[i].second) {
      vals[i - 1].first = last;
      vals[i - 1].second = spell[srted[i].first][0] - 1;
      q.insert({srted[i].first});
      int ind = 0;
      for (int a : q) {
        if (a != srted[i].first) {
          spells[i - 1].push_back(ind);
        } else {
          inserts[i] = ind;
        }
        ind++;
      }
      last = spell[srted[i].first][0];
    } else {
      vals[i - 1].first = last;
      vals[i - 1].second = spell[srted[i].first][1];
      int ind = 0;
      for (int a : q) {
        if (a != srted[i].first) {
          spells[i - 1].push_back(ind);
          ind++;
        } else {
          spells[i - 1].push_back(-1);
        }
      }
      q.erase(srted[i].first);
      last = spell[srted[i].first][1] + 1;
    }
  }
  dp[0][0] = 0;
  int ans = 0;
  for (int i = 0; i < 2 * n - 1; i++) {
    for (int mask = 0; mask < (1 << spells[i].size()); mask++) {
      int cnt = 0;
      int nxt = 0;
      for (int a = 0; a < spells[i].size(); a++) {
        if (mask & (1 << a)) {
          cnt++;
          if (spells[i][a] != -1) {
            nxt |= (1 << spells[i][a]);
          }
        }
      }
      if (dp[i][mask] == -1) {
        if (vals[i].second >= vals[i].first) {
          dp[i][mask] = dp[i][mask - (1 << inserts[i])] -
                        ((cnt - 1) % 2) * (vals[i].second - vals[i].first + 1);
        } else {
          dp[i][mask] = dp[i][mask - (1 << inserts[i])];
        }
      }
      if (vals[i].second >= vals[i].first) {
        dp[i][mask] += (cnt % 2) * (vals[i].second - vals[i].first + 1);
      }
      dp[i + 1][nxt] = max(dp[i + 1][nxt], dp[i][mask]);
      ans = max(ans, dp[i][mask]);
    }
  }
  cout << ans << "\n";
}
