#include <bits/stdc++.h>
using namespace std;
const int maxn = 1 << 18;
const long long inf = 1e18;
int n;
long long c;
vector<long long> s(maxn * 2), t(maxn), maxi(maxn * 4, -inf);
void update(int i, long long val) {
  i += maxn;
  maxi[i] = val;
  for (i = (i >> 1); i > 0; i >>= 1)
    maxi[i] = max(maxi[i * 2], maxi[i * 2 + 1]);
}
long long query(int l, int r) {
  long long val = -inf;
  for (l += maxn, r += maxn + 1; l < r; l >>= 1, r >>= 1) {
    if (l & 1) val = max(maxi[l++], val);
    if (r & 1) val = max(maxi[--r], val);
  }
  return val;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> c;
  for (int i = 1; i < 2 * n; i++) cin >> s[i], s[i] += s[i - 1];
  int l = 0;
  update(0, 0);
  for (int r = 1; r <= n; r++) {
    while (l < r && s[r * 2 - 1] - s[l * 2] > c) l++;
    if (l) t[r] = t[l - 1] + c;
    if (l < r) t[r] = max(t[r], s[r * 2 - 1] + query(l, r - 1));
    update(r, t[r] - s[r * 2]);
  }
  cout << t[n] << "\n";
  return 0;
}
