#include <bits/stdc++.h>
using namespace std;
long long s[2 * 200111];
deque<long long> dq;
long long dp[2 * 200111], val[2 * 200111];
long long query() {
  if (dq.empty()) return -(1LL << 61);
  return val[dq.front()];
}
int main() {
  long long n, c;
  scanf("%lld%lld", &n, &c);
  for (int i = 1; i < 2 * n; i++) {
    int a;
    scanf("%d", &a);
    s[i] = s[i - 1] + a;
  }
  dp[0] = val[0] = 0;
  dq.push_back(0);
  int j = 0;
  for (int i = 1; i <= n; i++) {
    while (s[2 * i - 1] - s[2 * j] > c && j < i) {
      if (!dq.empty() && dq.front() == j) dq.pop_front();
      j++;
    }
    if (j > 0) dp[i] = dp[j - 1] + c;
    dp[i] = max(dp[i], query() + s[2 * i - 1]);
    val[i] = dp[i] - s[2 * i];
    while (!dq.empty() && val[i] > val[dq.back()]) dq.pop_back();
    dq.push_back(i);
  }
  printf("%lld\n", dp[n]);
  return 0;
}
