#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
long long power(long long a, long long b) {
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans *= a;
    a = a * a;
    b >>= 1;
  }
  return ans;
}
long long powm(long long a, long long b) {
  a %= MOD;
  long long ans = 1;
  while (b > 0) {
    if (b & 1) ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    b >>= 1;
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int n, m;
  cin >> n >> m;
  vector<int> A(n);
  for (int &x : A) cin >> x;
  A.insert(A.begin(), 0);
  A.push_back(m);
  int totOn = 0;
  for (int i = 1; i <= n + 1; i += 2) totOn += A[i] - A[i - 1];
  int on = totOn, res = 0;
  for (int i = n; i >= 0; i--) {
    if (i % 2 == 0) {
      if (A[i + 1] - 1 > A[i])
        on = max(on, totOn - res + m - A[i + 1] - res - 1);
      res += A[i + 1] - A[i];
    } else {
      if (A[i + 1] - 1 > A[i]) on = max(on, totOn - res + m - A[i] - res - 1);
    }
  }
  cout << on << "\n";
  return 0;
}
