#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  long long C;
  cin >> C;
  long long ans = 0;
  vector<long long> x(N + 2, 0LL), v(N + 2, 0LL);
  for (int i = 0; i < (int)(N); i++) cin >> x[i + 1] >> v[i + 1];
  x[N + 1] = C;
  long long work = 0LL;
  for (int i = 1; i <= N; i++) {
    work += (v[i] - (x[i] - x[i - 1]));
    ans = max(ans, work);
  }
  work = 0LL;
  for (int i = 1; i <= N; i++) {
    work += (v[N + 1 - i] - (x[N + 2 - i] - x[N + 1 - i]));
    ans = max(ans, work);
  }
  for (int via = 1; via < N; via++) {
    work = 0LL;
    for (int i = 1; i <= via; i++) {
      work += (v[i] - (x[i] - x[i - 1]));
    }
    work -= x[via];
    for (int i = N; i > via; i--) {
      work += (v[i] - (x[i + 1] - x[i]));
      ans = max(ans, work);
    }
  }
  for (int via = N; via > 1; via--) {
    work = 0LL;
    for (int i = N; i >= via; i--) {
      work += (v[i] - (x[i + 1] - x[i]));
    }
    work -= (C - x[via]);
    for (int i = 1; i < via; i++) {
      work += (v[i] - (x[i] - x[i - 1]));
      ans = max(ans, work);
    }
  }
  cout << ans << endl;
  return 0;
}
