#include <bits/stdc++.h>
using namespace std;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline void Read(int& x) {
  char c = nc();
  for (; c < '0' || c > '9'; c = nc())
    ;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - 48, c = nc())
    ;
}
inline void Read(long long& x) {
  char c = nc();
  for (; c < '0' || c > '9'; c = nc())
    ;
  for (x = 0; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - 48, c = nc())
    ;
}
long long s[200010 << 1], t[200010], m, Ans, c[200010 << 2];
int i, j, k, n, x;
inline void Update(int x, int l, int r, int y, long long z) {
  if (l == r) {
    c[x] = z;
    return;
  }
  int Mid = l + r >> 1;
  if (y <= Mid)
    Update(x << 1, l, Mid, y, z);
  else
    Update(x << 1 | 1, Mid + 1, r, y, z);
  c[x] = max(c[x << 1], c[x << 1 | 1]);
}
inline long long Query(int x, int l, int r, int L, int R) {
  if (l > R || r < L) return -1e18;
  if (l >= L && r <= R) return c[x];
  int Mid = l + r >> 1;
  return max(Query(x << 1, l, Mid, L, R), Query(x << 1 | 1, Mid + 1, r, L, R));
}
int main() {
  Read(n);
  Read(m);
  for (i = 1; i <= n * 2 - 1; i++) Read(x), s[i] = s[i - 1] + x;
  for (i = 1; i <= n; i++) {
    for (; j < i && s[2 * i - 1] - s[2 * j] > m; j++)
      ;
    if (j > 0) t[i] = t[j - 1] + m;
    if (j < i) t[i] = max(t[i], s[i * 2 - 1] + Query(1, 0, n, j, i - 1));
    Update(1, 0, n, i, t[i] - s[i << 1]);
  }
  cout << t[n] << endl;
  return 0;
}
