#include <bits/stdc++.h>
using namespace std;
typedef struct practise2 {
  int on, off;
} bulb;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> v;
  v.push_back(0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    v.push_back(x);
  }
  v.push_back(m);
  int ans = 0;
  vector<bulb> li(n + 5);
  for (int i = 1; i < n + 2; i++) {
    if (i & 1) {
      li[i].on = v[i] - v[i - 1] + li[i - 1].on;
      li[i].off = li[i - 1].off;
    } else {
      li[i].off = v[i] - v[i - 1] + li[i - 1].off;
      li[i].on = li[i - 1].on;
    }
  }
  ans = li[n + 1].on;
  for (int i = 1; i <= n + 1; i++) {
    if (v[i] - 1 == v[i - 1]) {
      continue;
    }
    if (i & 1) {
      ans = max(ans, li[i].on - 1 + li[n + 1].off - li[i].off);
    } else {
      ans = max(ans, li[i - 1].on + li[n + 1].off - li[i - 1].off - 1);
    }
  }
  cout << ans;
}
