#include <bits/stdc++.h>
using namespace std;
int n, m, A[100005], Sum[100005], Suma[100005], i, val, rez;
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (i = 1; i <= n; i++) cin >> A[i];
  A[n + 1] = m;
  for (i = 1; i <= n + 1; i++) {
    Sum[i] = Sum[i - 1];
    Suma[i] = Suma[i - 1];
    if (i % 2 == 1)
      Sum[i] = Sum[i] + A[i] - A[i - 1];
    else
      Suma[i] = Suma[i] + A[i] - A[i - 1];
  }
  rez = Sum[n + 1];
  for (i = 0; i <= n + 1; i++) {
    if (i != 0 && A[i] - 1 != A[i - 1]) {
      if (i % 2 == 1)
        val = A[i] - A[i - 1] - 1;
      else
        val = 1;
      rez = max(rez, Sum[i - 1] + Suma[n + 1] - Suma[i] + val);
    }
    if (i != (n + 1) && A[i] + 1 != A[i + 1]) {
      if (i % 2 == 0)
        val = 1;
      else
        val = A[i + 1] - A[i] - 1;
      rez = max(rez, Sum[i] + val + Suma[n + 1] - Suma[i + 1]);
    }
  }
  cout << rez << "\n";
  return 0;
}
