#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 1;
int n;
long long c;
long long x[N], v[N];
long long l[N], r[N], b[N], bb[N];
int main() {
  cin >> n >> c;
  for (int i = (1); i <= (n); i++) {
    cin >> x[i] >> v[i];
    r[i] = r[i - 1] - (x[i] - x[i - 1]) + v[i];
  }
  b[n + 1] = -1e18;
  x[n + 1] = c;
  for (int i = n; i; i--) {
    l[i] = l[i + 1] - (x[i + 1] - x[i]) + v[i];
    b[i] = max(l[i], b[i + 1]);
    bb[i] = max(l[i] - c + x[i], bb[i + 1]);
  }
  long long ans = 0;
  for (int i = (0); i <= (n); i++) {
    long long A = max(r[i], 0LL);
    long long B = max(b[i + 1], 0LL);
    ans = max(ans, A);
    ans = max(ans, B);
    ans = max(ans, max(A + bb[i], A + B - x[i]));
  }
  cout << ans << endl;
}
