#include <bits/stdc++.h>
using namespace std;
int lowbit(int x) { return x & -x; }
int lbt(int x) { return __builtin_ctz(x); }
const int N = 100000;
int n, m, s;
int l[N + 1], r[N + 1];
vector<int> nums;
void discrete() {
  sort(nums.begin(), nums.end());
  nums.resize(unique(nums.begin(), nums.end()) - nums.begin());
  for (int i = 1; i <= n; i++)
    l[i] = lower_bound(nums.begin(), nums.end(), l[i]) - nums.begin(),
    r[i] = lower_bound(nums.begin(), nums.end(), r[i]) - nums.begin();
}
vector<int> in[3 * N + 1];
vector<int> dp[3 * N + 1];
int main() {
  cin >> n >> m >> s;
  nums.push_back(0);
  nums.push_back(m);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", l + i, r + i), nums.push_back(l[i] - 1), nums.push_back(r[i]);
  discrete();
  for (int i = 1; i <= n; i++)
    for (int j = l[i]; j <= r[i]; j++) in[j].push_back(i);
  dp[0].resize(1, 0);
  for (int i = 1; i < nums.size(); i++) {
    dp[i].resize(1 << in[i].size());
    vector<pair<int, int> > _and;
    for (int j = 0; j < in[i].size(); j++)
      for (int k = 0; k < in[i - 1].size(); k++)
        if (in[i][j] == in[i - 1][k]) _and.push_back(make_pair(j, k));
    vector<int> nin_and1, nin_and2;
    for (int j = 0, k = 0; j < in[i].size(); j++)
      if (k >= _and.size() || (j == _and[k].first ? k++, false : true))
        nin_and1.push_back(j);
    for (int j = 0, k = 0; j < in[i - 1].size(); j++)
      if (k >= _and.size() || (j == _and[k].second ? k++, false : true))
        nin_and2.push_back(j);
    vector<int> chg1(1 << _and.size(), 0), chg2(1 << nin_and1.size(), 0),
        chg3(1 << _and.size(), 0), chg4(1 << nin_and2.size(), 0);
    for (int j = 1; j < chg1.size(); j++)
      chg1[j] = chg1[j ^ lowbit(j)] | 1 << _and[lbt(j)].first;
    for (int j = 1; j < chg2.size(); j++)
      chg2[j] = chg2[j ^ lowbit(j)] | 1 << nin_and1[lbt(j)];
    for (int j = 1; j < chg3.size(); j++)
      chg3[j] = chg3[j ^ lowbit(j)] | 1 << _and[lbt(j)].second;
    for (int j = 1; j < chg4.size(); j++)
      chg4[j] = chg4[j ^ lowbit(j)] | 1 << nin_and2[lbt(j)];
    for (int j = 0; j < chg1.size(); j++) {
      int mx = 0;
      for (int k = 0; k < chg4.size(); k++)
        mx = max(mx, dp[i - 1][chg3[j] | chg4[k]]);
      for (int k = 0; k < chg2.size(); k++)
        dp[i][chg1[j] | chg2[k]] =
            mx + __builtin_parity(chg1[j] | chg2[k]) * (nums[i] - nums[i - 1]);
    }
  }
  cout << *max_element(dp[nums.size() - 1].begin(), dp[nums.size() - 1].end());
  return 0;
}
