#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100005;
int a[MAX_N];
int sum[MAX_N];
int main() {
  int n, M;
  cin >> n >> M;
  for (int i = 0; i < n; i++) cin >> a[i];
  sum[n - 1] = (M - a[n - 1]) * (n % 2 == 0);
  for (int i = n - 2; i >= 0; i--)
    sum[i] = sum[i + 1] + (a[i + 1] - a[i]) * (i % 2 != 0);
  int all_sum = sum[0] + a[0];
  a[n] = M;
  if (a[0] > 1) all_sum = max(all_sum, a[0] - 1 + (M - a[0] - sum[0]));
  int sum_pred = a[0];
  for (int i = 0; i < n; i++) {
    if (a[i + 1] > a[i] + 1)
      all_sum = max(all_sum, sum_pred + a[i + 1] - a[i] - 1 +
                                 (M - a[i + 1] - sum[i + 1]));
    if (i % 2 != 0) sum_pred += a[i + 1] - a[i];
  }
  cout << all_sum;
  return 0;
}
