#include <bits/stdc++.h>
using namespace std;
long long x[int(1e5 + 10)], v[int(1e5 + 10)], a[int(1e5 + 10)],
    b[int(1e5 + 10)];
int main() {
  long long n, c;
  while (~scanf("%lld%lld", &n, &c)) {
    for (int i = 1; i <= n; i++) {
      scanf("%lld%lld", &x[i], &v[i]);
      a[i] = a[i - 1] - x[i] + x[i - 1] + v[i];
    }
    x[n + 1] = c;
    for (int i = n; i > 0; i--) b[i] = b[i + 1] - x[i + 1] + x[i] + v[i];
    for (int i = 2; i <= n; i++) a[i] = max(a[i - 1], a[i]);
    for (int i = n - 1; i > 0; i--) b[i] = max(b[i + 1], b[i]);
    long long ma = 0;
    for (int i = 1; i <= n; i++) {
      ma = max(ma, a[i]);
      ma = max(ma, b[i]);
      ma = max(ma, a[i] - x[i] + b[i + 1]);
      ma = max(ma, b[i] - (c - x[i]) + a[i + 1]);
    }
    printf("%lld\n", ma);
  }
  return 0;
}
