#include <bits/stdc++.h>
using namespace std;
long long c;
long long x[100100] = {};
long long v[100100] = {};
long long a[100100] = {};
long long b[100100] = {};
long long cc[100100] = {};
long long cb[100100] = {};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n >> c;
  x[0] = 0;
  v[0] = 0;
  a[0] = 0;
  cc[0] = 0;
  x[n + 1] = c;
  a[n + 1] = 0;
  long long tmp = 0;
  long long tc = 0;
  for (int i = 1; i < n + 1; i++) {
    cin >> x[i] >> v[i];
    tmp += v[i] - (x[i] - x[i - 1]);
    if (tmp <= a[i - 1]) {
      a[i] = a[i - 1];
    } else {
      a[i] = tmp;
      tc = x[i];
    }
    cc[i] = tc;
  }
  tmp = 0;
  b[n + 1] = 0;
  cb[0] = c;
  tc = 0;
  for (int i = n; i >= 0; i--) {
    tmp += v[i] - (x[i + 1] - x[i]);
    if (tmp <= b[i + 1]) {
      b[i] = b[i + 1];
    } else {
      b[i] = tmp;
      tc = c - x[i];
    }
    cb[i] = tc;
  }
  long long ans = 0;
  for (int i = 0; i < (int)(n + 1); i++) {
    ans = max(ans, a[i]);
    ans = max(ans, b[i]);
  }
  for (int i = 0; i < (int)(n); i++) {
    ans = max(ans, a[i] - cc[i] + b[i + 1]);
  }
  for (int i = 1; i < n; i++) {
    ans = max(ans, b[i] - cb[i] + a[i - 1]);
  }
  cout << ans << endl;
  return 0;
}
