#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  {
    int x;
    cin >> x >> x;
  }
  vector<pair<int, int> > v;
  for (int i = 0, x, y; i < n; ++i)
    cin >> x >> y, v.emplace_back(x, i), v.emplace_back(y + 1, i - n);
  sort(v.begin(), v.end());
  int dp[1 << 8]{}, use = 0, pre = 0;
  vector<int> bit(n);
  bool ppcnt[1 << 8]{};
  for (int i = 0; i < 1 << 8; ++i) ppcnt[i] = __builtin_popcount(i) & 1;
  for (pair<int, int> ii : v) {
    int i = ii.second, tmp = ii.first - pre;
    if (i < 0) {
      i += n;
      use ^= 1 << bit[i];
      for (int j = 0; j < 1 << 8; ++j)
        if ((j | use) == use)
          dp[j] = max(dp[j] + tmp * ppcnt[j],
                      dp[j ^ 1 << bit[i]] + tmp * ppcnt[j ^ 1 << bit[i]]);
    } else {
      bit[i] = 0;
      while (use >> bit[i] & 1) ++bit[i];
      for (int j = 0; j < 1 << 8; ++j)
        if ((j | use) == use) dp[j ^ 1 << bit[i]] = dp[j] += tmp * ppcnt[j];
      use ^= 1 << bit[i];
    }
    pre = ii.first;
  }
  cout << dp[0];
}
