#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 4e5 + 5;
long long a[maxn], f[maxn], d[maxn];
int q[maxn];
int main() {
  int n, i, j, l, r;
  long long c;
  scanf("%d%lld", &n, &c);
  for (i = 1; i < (n << 1); i++) {
    scanf("%lld", &a[i]);
    a[i] += a[i - 1];
  }
  l = r = 1;
  j = q[1] = 0;
  for (i = 1; i <= n; i++) {
    while (j < i && a[(i << 1) - 1] - a[j << 1] > c) j++;
    while (l <= r && q[l] < j) l++;
    if (j) f[i] = f[j - 1] + c;
    if (l <= r) f[i] = max(f[i], d[q[l]] + a[(i << 1) - 1]);
    d[i] = f[i] - a[i << 1];
    while (l <= r && d[i] > d[q[r]]) r--;
    q[++r] = i;
  }
  printf("%lld\n", f[n]);
  return 0;
}
