#include <bits/stdc++.h>
using namespace std;
int n, m;
int a[200000], k[200000], g[200000];
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i + 1];
  a[0] = 0;
  if (n % 2 == 0)
    k[n] = m - a[n];
  else
    g[n] = m - a[n];
  for (int i = n - 1; i >= 0; i--) {
    g[i] = g[i + 1];
    k[i] = k[i + 1];
    if (i % 2)
      g[i] = a[i + 1] - a[i] + g[i + 1];
    else
      k[i] = a[i + 1] - a[i] + k[i + 1];
  }
  int ans = k[0];
  for (int i = 0; i <= n; i++) {
    if (a[i] > 1 && (a[i] - a[i - 1] != 1)) {
      if ((i - 1) % 2) {
        ans = max(ans, g[i] + 1 + k[0] - k[i]);
      } else {
        ans = max(ans, g[i] - 1 + k[0] - k[i]);
      }
    }
    if (a[i] < m - 1 && (i == n || a[i + 1] - a[i] != 1)) {
      if (i % 2)
        ans = max(ans, g[i] - 1 + k[0] - k[i]);
      else
        ans = max(ans, g[i] + 1 + k[0] - k[i]);
    }
  }
  cout << ans;
  return 0;
}
