#include <bits/stdc++.h>
using namespace std;
int a[100090];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, M;
  cin >> n >> M;
  for (int i = 0; i < n; ++i) cin >> a[i + 1];
  a[n + 1] = M;
  a[0] = 0;
  int lit[2] = {0};
  int orgin = 0, ans = 0;
  for (int i = 0; i < n + 1; i += 2) ans += a[i + 1] - a[i];
  orgin = ans;
  for (int i = n; i >= 1; --i) {
    lit[1 - i % 2] += a[i + 1] - a[i];
    if (a[i] + 1 != a[i + 1])
      ans = max(orgin + lit[0] - lit[1] + (1 - i % 2 ? 1 : -1), ans);
    if (a[i] - 1 != a[i - 1])
      ans = max(orgin + lit[0] - lit[1] + (1 - i % 2 ? 1 : -1), ans);
  }
  lit[1] += a[1];
  if (a[1] != 1) ans = max(orgin + lit[0] - lit[1] + 1, ans);
  cout << ans << '\n';
}
