#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
const int INF = 1.01e9;
const long long INF18 = 1.01e18;
int main() {
  int n;
  long long C;
  scanf("%d%lld", &n, &C);
  vector<long long> a(n);
  vector<long long> b(n - 1);
  for (int i = 0; i < (n); i++) {
    scanf("%lld", &a[i]);
    if (i + 1 != n) {
      scanf("%lld", &b[i]);
    }
  }
  b.push_back(0);
  vector<long long> c(n);
  set<pair<long long, int>> q;
  long long shift = 0;
  vector<long long> hist(n);
  int cur = 0;
  vector<long long> prefB;
  prefB.push_back(0);
  for (int i = 0; i < n; i++) {
    prefB.push_back(prefB.back() + a[i] + b[i]);
  }
  vector<long long> prefC;
  prefC.push_back(0);
  for (int i = 0; i < n; i++) {
    if (i > 0) {
      long long diff = b[i - 1] - c[i - 1];
      shift += diff;
      q.insert({-shift, i});
      hist[i] = -shift;
    }
    if (i == 0) {
      q.insert({0, i});
      hist[i] = 0;
    }
    for (; cur < i && (prefB[i] - prefB[cur]) + a[i] > C;) {
      assert(q.erase({hist[cur], cur}));
      cur++;
    }
    long long val = 0;
    if (!q.empty()) {
      val = max(q.rbegin()->first + shift, val);
    }
    val = max(
        min(prefB[i] + a[i], C) - ((prefC[i] - prefC[max(0, cur - 1)]) + a[i]),
        val);
    c[i] = val;
    prefC.push_back(prefC.back() + a[i] + c[i]);
  }
  long long answer = 0;
  for (auto x : c) {
    answer += x;
  }
  for (auto x : a) {
    answer += min(x, C);
  }
  cout << answer << endl;
  return 0;
}
