#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
long long n, c;
long long x[10005];
long long v[10005];
int main() {
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> v[i];
  }
  long long ans = 0;
  for (int i = -1; i < n; i++) {
    long long tot_r = 0;
    for (int j = 0; j <= i; j++) {
      tot_r += v[j];
      ans = max(ans, tot_r - x[j]);
    }
    if (i > -1) {
      tot_r -= 2 * x[i];
    }
    long long tot_l = 0;
    for (int j = n - 1; j > i; j--) {
      tot_l += v[j];
      ans = max(ans, tot_r + tot_l - c + x[j]);
    }
  }
  cout << ans << endl;
  return 0;
}
