#include <bits/stdc++.h>
long long s[400001], a[200001], c;
int n, q[200001], l = 0, r = 1, k = 0;
int main() {
  scanf("%d%lld", &n, &c);
  for (int i = 1; i < 2 * n; i++) {
    scanf("%lld", s + i);
    s[i] += s[i - 1];
  }
  for (int i = 1; i <= n; i++) {
    while (k < i && s[2 * i - 1] - s[2 * k] >= c) k++;
    while (l < r && q[l] < k) l++;
    a[i] = l < r ? a[q[l]] - s[2 * q[l]] + s[2 * i - 1] : -1e18;
    if (k) a[i] = (a[i] > a[k - 1] + c ? a[i] : a[k - 1] + c);
    while (l < r && a[q[r - 1]] - s[2 * q[r - 1]] <= a[i] - s[2 * i]) r--;
    q[r++] = i;
  }
  printf("%lld\n", a[n]);
}
