#include <bits/stdc++.h>
using namespace std;
int arr[100000 + 5];
long long cool[100000 + 5];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N, M, i;
  long long curr, ans, b;
  cin >> N >> M;
  for (i = 1; i <= N; ++i) cin >> arr[i];
  arr[0] = 0;
  arr[N + 1] = M;
  for (i = N; i >= 0; --i) {
    cool[i] = cool[i + 1];
    if (i & 1) cool[i] += arr[i + 1] - arr[i];
  }
  ans = b = 0;
  for (i = 0; i <= N; ++i) {
    if (arr[i + 1] - arr[i] == 1) {
      if (i % 2 == 0) b += 1;
      continue;
    }
    if (i % 2 == 0) {
      curr = arr[i + 1] - 1 - arr[i];
      curr += cool[i + 1];
      curr += b;
      ans = max(ans, curr);
      b += arr[i + 1] - arr[i];
    } else {
      curr = arr[i + 1] - arr[i] - 1;
      curr += cool[i + 1];
      curr += b;
      ans = max(ans, curr);
    }
  }
  ans = max(ans, b);
  cout << ans;
  return 0;
}
