#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  long long on[n + 2];
  long long is[n + 1];
  int inst[n + 2];
  is[0] = 1;
  int pval = m;
  inst[0] = 0;
  for (int i(1); i <= n; i++) {
    cin >> inst[i];
    if (is[i - 1] == 0) {
      is[i] = 1;
    } else
      is[i] = 0;
  }
  inst[n + 1] = m;
  if (is[n] == 1) {
    on[n] = m - inst[n];
    pval = inst[n];
  } else {
    on[n] = 0;
    pval = inst[n];
  }
  for (int i(n - 1); i >= 1; --i) {
    if (is[i] == 1) {
      on[i] = on[i + 1] + (pval - inst[i]);
      pval = inst[i];
    } else {
      on[i] = on[i + 1];
      pval = inst[i];
    }
  }
  on[0] = on[1] + inst[1] - 0;
  pval = 0;
  on[n + 1] = 0;
  long long ans = on[0];
  for (int i(0); i <= n; i++) {
    if (inst[i + 1] - inst[i] < 2) {
      continue;
    } else {
      long long l, m1, r;
      l = on[0] - on[i];
      m1 = inst[i + 1] - inst[i] - 1;
      r = m - inst[i + 1] - on[i + 1];
      ans = max(ans, l + m1 + r);
    }
  }
  cout << ans;
}
