#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long n, c;
  cin >> n >> c;
  long long v[2 * n - 1];
  for (long long i = 0; i < 2 * n - 1; i++) {
    cin >> v[i];
    if (i % 2 == 0) v[i] = min(v[i], c);
  }
  long long prefix[2 * n];
  prefix[0] = 0;
  for (long long i = 0; i < 2 * n - 1; i++) {
    prefix[i + 1] = prefix[i] + v[i];
  }
  set<pair<long long, long long> > ms;
  long long pl = 0;
  long long pays[n], sets[n];
  long long sp = 0;
  long long cand = 0;
  long long ans = 0;
  for (long long i = 0; i < n; i++) {
    while (cand < i) {
      long long treb = prefix[2 * i + 1] - prefix[2 * cand];
      if (treb > c) {
        set<pair<long long, long long> >::iterator it =
            ms.upper_bound(make_pair(sets[cand], cand - 1));
        ms.erase(it);
        cand++;
        sp -= pays[cand - 1];
      } else
        break;
    }
    long long now_pay = 0;
    if (cand > 0) {
      long long w = sp + pays[cand - 1];
      now_pay = c - w;
    }
    if (ms.size() > 0) {
      set<pair<long long, long long> >::iterator it = ms.end();
      it--;
      pair<long long, long long> p = *it;
      long long mon = p.first + pl + v[2 * i];
      now_pay = max(now_pay, mon);
    } else
      now_pay = max(now_pay, v[2 * i]);
    pays[i] = now_pay;
    ans += pays[i];
    if (i == n - 1) break;
    long long please = -pays[i] + v[2 * i] + v[2 * i + 1];
    sets[i] = -pl;
    sp += pays[i];
    ms.insert(make_pair(-pl, i));
    pl += please;
  }
  cout << ans << endl;
  return 0;
}
