#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
int main() {
  fast();
  long long n, m, l = 0, d = 0;
  cin >> n >> m;
  vector<pair<long long, long long>> a, front, back;
  a.push_back(make_pair(0, 1));
  int c = 0;
  for (int i = 1; i <= n; ++i) {
    long long temp;
    cin >> temp;
    a.push_back(make_pair(temp, c));
    c = !c;
  }
  a.push_back(make_pair(m, 0));
  front.push_back(make_pair(0, 0));
  for (int i = 1; i < a.size(); ++i) {
    int temp = a[i].first - a[i - 1].first;
    if (n % 2 && i == a.size() - 1) {
      d += temp;
      front.push_back(make_pair(l, d));
      continue;
    }
    if (a[i].second == 0)
      l += temp;
    else
      d += temp;
    front.push_back(make_pair(l, d));
  }
  back.push_back(make_pair(0, 0));
  for (int i = 1; i < a.size(); ++i)
    back.push_back(make_pair(d - front[i].second, l - front[i].first));
  long long f_ans = l;
  for (int i = 1; i < a.size(); ++i) {
    long long temp = a[i].first - a[i - 1].first,
              ans = front[i].first - 1 + back[i].first;
    if (!i % 2) ans += temp;
    f_ans = max(f_ans, ans);
  }
  cout << f_ans << '\n';
}
