#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  long long a[n + 2];
  a[0] = 0, a[n + 1] = m;
  int op = 0, of = 0, maxx = 0;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i >= 0; i--) {
    if (i % 2 == 0)
      op += a[i + 1] - a[i];
    else
      of += a[i + 1] - a[i];
    maxx = max(maxx, of - op);
  }
  if (maxx == 0)
    cout << op;
  else
    cout << op + maxx - 1;
}
