#include <bits/stdc++.h>
using namespace std;
template <typename t>
t in(t q) {
  cin >> q;
  return q;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < ((int)size(v)); ++i) {
    os << v[i];
    if (i != ((int)size(v)) - 1) os << ",";
  }
  os << "]";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto it : v) os << "(" << it.first << ":" << it.second << ")";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << "(";
  os << v.first << "," << v.second << ")";
  return os;
}
const double PI = acos(-1);
int a[(1 * 100005)];
int odds[(1 * 100005)];
int evens[(1 * 100005)];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(25);
  int n, M;
  cin >> n >> M;
  for (__typeof(n + 1) i = (1) - ((1) > (n + 1));
       i != (n + 1) - ((1) > (n + 1)); i += 1 - 2 * ((1) > (n + 1))) {
    cin >> a[i];
  }
  a[n + 1] = M;
  for (__typeof(n + 2) i = (1) - ((1) > (n + 2));
       i != (n + 2) - ((1) > (n + 2)); i += 1 - 2 * ((1) > (n + 2))) {
    odds[i] = odds[i - 1];
    if (i & 1) odds[i] += (a[i] - a[i - 1]);
  }
  for (__typeof(n + 3) i = (1) - ((1) > (n + 3));
       i != (n + 3) - ((1) > (n + 3)); i += 1 - 2 * ((1) > (n + 3))) {
    evens[i] = evens[i - 1];
    if (!(i & 1)) evens[i] += (a[i] - a[i - 1]);
  }
  int sum = 0;
  for (__typeof(n + 2) i = (1) - ((1) > (n + 2));
       i != (n + 2) - ((1) > (n + 2)); i += 1 - 2 * ((1) > (n + 2))) {
    if (i % 2 == 0) {
      sum += (a[i] - a[i - 1]);
    }
  }
  int bes = odds[n + 1];
  for (__typeof(n + 2) i = (1) - ((1) > (n + 2));
       i != (n + 2) - ((1) > (n + 2)); i += 1 - 2 * ((1) > (n + 2))) {
    if (a[i] - a[i - 1] < 2) continue;
    if (i & 1) {
      int before = odds[i - 1], after = sum - evens[i];
      bes = max(before + after + (a[i] - a[i - 1] - 1), bes);
    } else {
      int before = odds[i - 1], after = sum - evens[i];
      bes = max(before + after + (a[i] - a[i - 1] - 1), bes);
    }
  }
  cout << bes;
  return 0;
}
