#include <bits/stdc++.h>
using namespace std;
int n;
long long int c;
vector<long long int> v;
vector<long long int> vv;
vector<long long int> have;
deque<pair<long long int, int> > d;
long long int im[200002];
long long int gt(int idx) {
  if (idx < 0) {
    return 0;
  }
  return im[idx];
}
priority_queue<pair<long long int, int> > q;
int main() {
  cin >> n;
  cin >> c;
  long long int ans = 0;
  for (int i = 0; i < 2 * n - 1; i++) {
    int a;
    scanf("%d", &a);
    if (i % 2 == 0) {
      v.push_back(a);
    } else {
      vv.push_back(a);
    }
  }
  have.assign(v.size(), 0);
  have[0] = min(c, v[0]);
  d.push_back(make_pair(0, 0));
  q.push(make_pair(0, 0));
  im[0] = have[0];
  long long int sum = have[0];
  for (int i = 1; i < v.size(); i++) {
    while (d.size() && sum - d.front().first >= c) {
      d.pop_front();
    }
    sum += vv[i - 1];
    d.push_back(make_pair(sum, i));
    q.push(make_pair(-sum + gt(i - 1), i));
    sum += v[i];
    im[i] = im[i - 1];
    long long int mx = 0;
    while (d.size() && sum - d.front().first >= c) {
      mx = max(mx, c - (im[i - 1] - gt(d.front().second - 1)));
      d.pop_front();
    }
    while (!q.empty()) {
      if (d.size() == 0 || q.top().second < d.front().second) {
        q.pop();
        continue;
      }
      long long int mm = q.top().first + sum - im[i - 1];
      mx = max(mx, mm);
      break;
    }
    mx = min(mx, (long long int)c);
    have[i] = mx;
    im[i] += have[i];
  }
  long long int sum2 = 0;
  for (int i = 0; i < n; i++) {
    sum2 += have[i];
  }
  printf("%lld\n", sum2);
  return 0;
}
