#include <bits/stdc++.h>
using namespace std;
const int Nmax = 4e5 + 5;
deque<int> dq;
int i, k, n, x;
long long sum[Nmax], best[Nmax], dp[Nmax], C;
int main() {
  cin.sync_with_stdio(false);
  cin >> n >> C;
  for (i = 1; i < 2 * n; ++i) {
    cin >> x;
    sum[i] = x + sum[i - 1];
  }
  k = 0;
  for (i = 1; i <= n; ++i) {
    best[i] = dp[i - 1] - sum[2 * i - 2];
    while (dq.size() && best[dq.back()] <= best[i]) dq.pop_back();
    dq.push_back(i);
    while (sum[2 * k] < sum[2 * i - 1] - C && k < i) ++k;
    while (dq.size() && dq.front() <= k) dq.pop_front();
    if (k) dp[i] = C + dp[k - 1];
    if (dq.size()) dp[i] = max(dp[i], sum[2 * i - 1] + best[dq.front()]);
  }
  cout << dp[n] << '\n';
  return 0;
}
