#include <bits/stdc++.h>
using namespace std;
struct change {
  int x = 0;
  int before_state = -1;
  int svetlelo = 0;
  int ns() { return x - svetlelo; }
};
change a[100013];
int f(int a) { return (a + 1) / 2; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cerr.tie(nullptr);
  cout.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int x;
  for (int i = 1; i <= n + 1; i++) {
    x = m;
    if (i != n + 1) cin >> x;
    a[i].x = x;
    a[i].before_state = -1 * a[i - 1].before_state;
    a[i].svetlelo =
        a[i - 1].svetlelo + f(a[i].before_state) * (a[i].x - a[i - 1].x);
  }
  int sol = a[n + 1].svetlelo;
  for (int i = 1; i <= n; i++) {
    change cur;
    cur.x = a[i].x - 1;
    if (cur.x != a[i - 1].x) {
      cur.before_state = a[i].before_state;
      cur.svetlelo = a[i].svetlelo - f(a[i].before_state);
      sol = max(sol, a[n + 1].ns() - cur.ns() + cur.svetlelo);
    }
    cur.x = a[i].x + 1;
    if (cur.x != a[i + 1].x) {
      cur.before_state = !a[i].before_state;
      cur.svetlelo = a[i].svetlelo + f(cur.before_state);
      sol = max(sol, a[n + 1].ns() - cur.ns() + cur.svetlelo);
    }
  }
  cout << sol << endl;
}
