#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
long long pson[MAXN], psof[MAXN], a[MAXN], n, M, maxi;
int main() {
  cin >> n >> M;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[0] = 0;
  a[n + 1] = M;
  for (int i = n; i >= 0; i--) {
    pson[i] = pson[i + 1];
    psof[i] = psof[i + 1];
    if (i % 2 == 1)
      psof[i] += a[i + 1] - a[i];
    else
      pson[i] += a[i + 1] - a[i];
  }
  maxi = pson[0];
  for (int i = 0; i <= n; i++)
    if (a[i] + 1 != a[i + 1]) {
      if (i % 2 == 1)
        maxi = max(maxi, pson[0] - pson[i] + psof[i] - 1);
      else
        maxi = max(maxi, pson[0] - pson[i + 1] + psof[i + 1] - 1);
    }
  cout << maxi;
}
