#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 5;
int n;
long long c;
long long s[2 * MAXN];
long long pref[2 * MAXN];
long long sum(int lo, int hi) {
  assert(lo <= hi);
  return pref[2 * hi + 1] - pref[2 * lo];
}
long long _monic[MAXN];
long long *monic = _monic + 1;
long long f(int id) {
  return -(monic[id - 1] - sum(0, n - 1) + sum(id, n - 1));
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> c;
  for (int i = (int)(0); i < (int)(2 * n - 1); ++i) cin >> s[i];
  pref[0] = 0;
  for (int i = (int)(0); i < (int)(2 * n - 1); ++i)
    pref[i + 1] = pref[i] + s[i];
  monic[-1] = 0;
  int low = 0;
  set<pair<long long, int>> S;
  for (int i = (int)(0); i < (int)(n); ++i) {
    S.insert({f(i), i});
    for (; low <= i && sum(low, i) >= c; ++low) S.erase({f(low), low});
    if (low)
      monic[i] = monic[low - 2] + min(c, sum(low - 1, i));
    else
      monic[i] = min(c, sum(0, i));
    if (!S.empty()) {
      int first = S.begin()->second;
      monic[i] = max(monic[i], monic[first - 1] + min(c, sum(first, i)));
    }
  }
  cout << monic[n - 1] << endl;
  return 0;
}
