#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long C;
  scanf("%d %ld", &N, &C);
  long v = 0;
  long x = 0;
  long temp = 0;
  long xs[N];
  long vs[N];
  long c[N];
  long d[N];
  for (int i = 0; i < N; ++i) {
    scanf("%ld %ld", &x, &v);
    xs[i] = x;
    vs[i] = v;
    c[i] = v - (x - temp);
    d[i] = (i == 0) ? c[0] : d[i - 1] + c[i];
    temp = x;
  }
  long* p = max_element(d, d + N);
  long ans = *p;
  int index = distance(d, p);
  if (ans > 0) {
    for (int i = N - 1; i > -1; --i) {
      if (index == i) break;
      if (vs[i] - (C - xs[i]) > 0) {
        ans += vs[i] - (C - xs[i]);
      } else {
        break;
      }
    }
    printf("%ld\n", ans);
  } else {
    printf("0\n");
  }
  return 0;
}
