#include <bits/stdc++.h>
using namespace std;
const int dir[8][2] = {{0, 1}, {1, 0},  {0, -1},  {-1, 0},
                       {1, 1}, {1, -1}, {-1, -1}, {-1, 1}};
const int mod = 1e9 + 7, gakki = 5 + 2 + 1 + 19880611 + 1e9;
const int MAXN = 2e5 + 5, MAXM = 2e5 + 5, N = 2e5 + 5;
const int MAXQ = 100010;
inline void read(int &v) {
  v = 0;
  char c = 0;
  int p = 1;
  while (c < '0' || c > '9') {
    if (c == '-') {
      p = -1;
    }
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    v = (v << 3) + (v << 1) + c - '0';
    c = getchar();
  }
  v *= p;
}
int num[200005];
int anser = 0;
int number[200005];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> num[i];
  }
  n++;
  num[n] = m;
  for (int i = 1; i <= n; i++) {
    number[i] = number[i - 1];
    if (i & 1) {
      int add = num[i] - num[i - 1];
      number[i] += add;
    }
  }
  anser = number[n];
  for (int i = 1; i <= n - 1; i++) {
    if (num[i] - 1 > num[i - 1] || num[i] + 1 < num[i + 1]) {
      if (i & 1) {
        int now = number[i] + m - num[i] + number[i] - number[n] - 1;
        anser = max(anser, now);
      }
    }
  }
  cout << anser << endl;
  return 0;
}
