#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f2f1f0f;
const long long LINF = 1ll * INF * INF;
const int MAX_N = 2e5 + 100;
int N;
long long C;
int Nr[MAX_N * 2];
long long SumNr[MAX_N * 2];
long long Ans[MAX_N];
long long SumAns[MAX_N];
long long getSum(long long val[], int a, int b) { return val[b] - val[a - 1]; }
long long getVal(int a, int b) {
  return getSum(SumNr, a * 2 - 1, b * 2 - 1) - getSum(SumAns, a, b - 1);
}
int main() {
  cin >> N >> C;
  for (int i = 1; i <= N * 2 - 1; i++)
    scanf("%d", &Nr[i]), SumNr[i] = SumNr[i - 1] + Nr[i];
  deque<int> dQ;
  int cl = 0;
  for (int r = 1; r <= N; r++) {
    while (!dQ.empty() && getVal(dQ.back(), r) < Nr[r * 2 - 1]) dQ.pop_back();
    dQ.push_back(r);
    while (!dQ.empty() && getSum(SumNr, dQ.front() * 2 - 1, r * 2 - 1) >= C)
      dQ.pop_front();
    while (cl + 1 <= N && getSum(SumNr, (cl + 1) * 2 - 1, r * 2 - 1) >= C) cl++;
    if (cl != 0) Ans[r] = max(Ans[r], C - getSum(SumAns, cl, r - 1));
    if (!dQ.empty()) Ans[r] = max(Ans[r], getVal(dQ.front(), r));
    SumAns[r] = SumAns[r - 1] + Ans[r];
  }
  printf("%lld\n", SumAns[N]);
  return 0;
}
