#include <bits/stdc++.h>
using namespace std;
struct Vec {
  long x;
  int index;
};
bool xdesc(const Vec& left, const Vec& right) {
  return left.x == right.x ? left.x > right.x : left.x > right.x;
}
int main(void) {
  long ans, N, C, x[100002], v[100002], dif[100002], dif_r[100002], ret, ret_r;
  x[0] = (long)0;
  ret = (long)0;
  ret_r = (long)0;
  v[0] = (long)0;
  dif[0] = (long)0;
  dif_r[0] = (long)0;
  vector<Vec> d, d_r;
  scanf("%ld%ld", &N, &C);
  x[N + 1] = C;
  dif_r[N + 1] = 0;
  for (int i = 1; i < N + 1; i++) {
    scanf("%ld%ld", &x[i], &v[i]);
    dif[i] = dif[i - 1] + v[i] + x[i - 1] - x[i];
    if (dif[i] - x[i] > 0) ret = dif[i] - x[i];
    Vec v = {dif[i], i};
    d.push_back(v);
  }
  sort(d.begin(), d.end(), xdesc);
  for (int i = N; i > 0; i--) {
    dif_r[i] = dif_r[i + 1] + v[i] + (C - x[i + 1]) - (C - x[i]);
    if (dif_r[i] - (C - x[i]) > 0) ret_r = dif_r[i] - (C - x[i]);
    Vec v_r = {dif_r[i], i};
    d_r.push_back(v_r);
  }
  sort(d_r.begin(), d_r.end(), xdesc);
  if (d[0].x > d_r[0].x)
    ans = d[0].x + ret_r;
  else
    ans = d_r[0].x + ret;
  if (ans < (long)0) ans = (long)0;
  printf("%ld\n", ans);
  fflush(stdout);
  return 0;
}
