#include <bits/stdc++.h>
using namespace std;
const int maxn = 100010;
int n;
long long c, x[maxn];
long long f[maxn], g[maxn], t[maxn], r[maxn], a[maxn], b[maxn], v[maxn];
int main() {
  cin >> n >> c;
  for (register int i = 1; i <= n; ++i) scanf("%lld%lld", &x[i], &v[i]);
  b[n + 1] = x[n + 1] = c;
  for (register int i = 1; i <= n; ++i) {
    f[i] = f[i - 1] + v[i] + x[i - 1] - x[i];
    t[i] = max(t[i - 1], max(f[i], f[i - 1]));
    if (t[i] == t[i - 1])
      a[i] = a[i - 1];
    else
      a[i] = x[i];
  }
  for (register int i = n; i; --i) {
    g[i] = g[i + 1] + v[i] + x[i] - x[i + 1];
    r[i] = max(r[i - 1], max(g[i], g[i - 1]));
    if (r[i] == r[i + 1])
      b[i] = b[i + 1];
    else
      b[i] = x[i];
  }
  long long ans = 0;
  for (register int i = 1; i < n; ++i) {
    ans = max(t[i] + r[i + 1] - a[i], ans);
    ans = max(r[i + 1] + t[i] - c + b[i + 1], ans);
  }
  ans = max(ans, t[n]);
  ans = max(ans, r[1]);
  cout << ans << endl;
  return 0;
}
