#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
using matrix = vector<vector<long long>>;
const int MAXN = 1e5 + 100;
int a[MAXN];
int seg[MAXN];
long long on[MAXN], off[MAXN];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  seg[0] = a[0] - 0;
  for (int i = 1; i < n; ++i) {
    seg[i] = a[i] - a[i - 1];
  }
  seg[n] = m - a[n - 1];
  for (int i = n; i >= 0; --i) {
    if (i % 2 == 0) {
      on[i] = seg[i];
    } else {
      off[i] = seg[i];
    }
    on[i] += on[i + 1];
    off[i] += off[i + 1];
  }
  long long ans = on[0];
  for (int i = 0; i <= n; ++i) {
    if (seg[i] == 1) {
      continue;
    }
    ans = max(ans, on[0] - on[i] + seg[i] - 1 + off[i + 1]);
  }
  cout << ans;
}
