#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N, C;
  long long x[100010] = {}, v[100010] = {};
  cin >> N >> C;
  for (int i = 1; i <= N; i++) {
    cin >> x[i] >> v[i];
  }
  x[N + 1] = C;
  long long forward_sum[100001] = {}, backward_sum[100001] = {};
  for (int i = 1; i <= N; i++) {
    forward_sum[i] = forward_sum[i - 1] - (x[i] - x[i - 1]) + v[i];
    backward_sum[i] = backward_sum[i - 1] -
                      (x[N + 1 + 1 - i] - x[N + 1 + 1 - i - 1]) + v[N + 1 - i];
  }
  pair<long long, long long> forward[100001], backward[100001];
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    ans = max(ans, forward_sum[i]);
    ans = max(ans, backward_sum[i]);
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; i + j <= N; j++) {
      ans = max(ans, forward_sum[i] + backward_sum[j] - x[i]);
    }
  }
  for (int i = 1; i <= N; i++) {
    for (int j = 1; i + j <= N; j++) {
      ans = max(ans,
                backward_sum[i] + forward_sum[j] - (x[N + 1] - x[N + 1 - i]));
    }
  }
  cout << ans << endl;
}
