#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200100;
int N;
long long C;
long long sz[MAXN];
long long hsz[MAXN];
long long res[MAXN];
long long psum[MAXN];
pair<int, long long> v[MAXN];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> N >> C;
  for (int i = 0; i < 2 * N - 1; i++) {
    if (i % 2 == 0)
      cin >> sz[i / 2];
    else
      cin >> hsz[i / 2];
  }
  int lo = 0;
  int vstart = 0, vend = 1;
  v[0] = make_pair(-1, 0);
  long long bsum = 0;
  long long rsum = 0;
  long long cscore = 0;
  long long tot = 0;
  for (int i = 0; i < N; i++) {
    long long ans = min(C, sz[i]);
    bsum += sz[i];
    while (true) {
      if (bsum >= C) {
        ans = max(ans, C - rsum);
        while (vstart < vend && v[vstart].first <= lo - 1) vstart++;
      }
      if (bsum - sz[lo] - hsz[lo] >= C) {
        bsum -= sz[lo] + hsz[lo];
        rsum -= res[lo];
        while (vstart < vend && v[vstart].first <= lo) vstart++;
        lo++;
      } else
        break;
    }
    if (vstart < vend) ans = max(ans, sz[i] + cscore - v[vstart].second);
    ans = min(C, ans);
    tot += ans;
    res[i] = ans;
    cscore += sz[i] + hsz[i] - res[i];
    psum[i] = cscore;
    bsum += hsz[i];
    rsum += res[i];
    while (vstart < vend) {
      if (v[vend - 1].second >= cscore)
        vend--;
      else
        break;
    }
    v[vend++] = make_pair(i, cscore);
  }
  cout << tot << "\n";
  return 0;
}
