#include <bits/stdc++.h>
using namespace std;
const int MAXN = 210000;
const long long INF = 1e16;
int n;
long long c;
long long a[MAXN];
long long b[MAXN];
long long sm[MAXN];
long long ans[MAXN];
long long dd[MAXN * 4];
long long rmq[MAXN * 4];
void add(int v, int tl, int tr, int l, int r, long long d) {
  if (r <= tl || tr <= l) return;
  if (l <= tl && tr <= r) {
    dd[v] += d;
    rmq[v] += d;
    return;
  }
  int m = (tl + tr) >> 1;
  add(v * 2 + 1, tl, m, l, r, d);
  add(v * 2 + 2, m, tr, l, r, d);
  rmq[v] = min(rmq[v * 2 + 1], rmq[v * 2 + 2]) + dd[v];
}
long long get(int v, int tl, int tr, int l, int r) {
  if (r <= tl || tr <= l) return INF;
  if (l <= tl && tr <= r) return rmq[v];
  int m = (tl + tr) >> 1;
  return min(get(v * 2 + 1, tl, m, l, r), get(v * 2 + 2, m, tr, l, r)) + dd[v];
}
int main() {
  scanf("%d%lld", &n, &c);
  scanf("%lld", a + 0);
  for (int i = 1; i < n; ++i) {
    scanf("%lld%lld", b + i, a + i);
  }
  for (int i = 0; i < n; ++i) a[i] = min(a[i], c), b[i] = min(b[i], c);
  sm[0] = 0;
  sm[1] = a[0];
  for (int i = 1; i < n; ++i) {
    long long lb = a[i] - 1;
    long long rb = a[i] + b[i];
    add(0, 0, n, 0, i + 1, -a[i]);
    add(0, 0, n, 0, i, -b[i]);
    while (rb - lb > 1) {
      long long mid = (lb + rb) >> 1;
      long long sn = sm[i] + mid;
      int x = upper_bound(sm, sm + i + 1, sn - c) - sm;
      if (get(0, 0, n, x, i + 1) + mid >= 0)
        rb = mid;
      else
        lb = mid;
    }
    add(0, 0, n, 0, i + 1, rb);
    sm[i + 1] = sm[i] + rb;
  }
  cout << sm[n] << "\n";
  return 0;
}
