#include <bits/stdc++.h>
using namespace std;
long long n, c, x[100001], v[100001];
long long solve2(int rIndex, long long rValue) {
  long long pos = x[rIndex];
  long long mx = rValue;
  long long current = rValue;
  current -= pos;
  pos = c;
  for (int i = n - 1; i > rIndex; i--) {
    current -= (pos - x[i]);
    current += v[i];
    if (mx < current) mx = current;
    pos = x[i];
  }
  return mx;
}
long long solve() {
  long long mx = 0;
  long long pos = 0;
  long long current = 0;
  for (int i = (0), ilen = (n); i < ilen; ++i) {
    current -= (x[i] - pos);
    current += v[i];
    pos = x[i];
    long long tmx = solve2(i, current);
    if (tmx > mx) mx = tmx;
  }
  return mx;
}
int main(void) {
  scanf("%lld %lld", &n, &c);
  for (int i = (0), ilen = (n); i < ilen; ++i) {
    scanf("%lld %lld", &(x[i]), &(v[i]));
  }
  long long res1 = solve();
  reverse(x, x + n);
  reverse(v, v + n);
  for (int i = (0), ilen = (n); i < ilen; ++i) {
    x[i] = c - x[i];
  }
  long long res2 = solve();
  long long res = max(res1, res2);
  cout << res << endl;
  return 0;
}
