#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005], b[100005], len[100005], sum1[100005], sum2[100005], ans;
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[0] = 0, a[n + 1] = m;
  sort(a, a + n + 2);
  for (int i = 1; i <= n + 1; i++) {
    len[i] = a[i] - a[i - 1];
    if (i % 2) ans += len[i];
  }
  for (int i = 1; i <= n + 1; i++) {
    sum1[i] = sum1[i - 1] + ((i % 2) ? len[i] : 0);
    sum2[i] = sum2[i - 1] + ((!(i % 2)) ? len[i] : 0);
  }
  for (int i = 1; i <= n + 1; i++) {
    if (len[i] == 1) continue;
    int cnt = sum1[i - 1] + len[i] - 1 + sum2[n + 1] - sum2[i];
    ans = max(ans, cnt);
  }
  cout << ans;
  return 0;
}
