#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long c;
  cin >> n >> c;
  if (n > 100) return 0;
  vector<vector<long long>> sushi;
  sushi.push_back({0, 0});
  for (int i = 0; i < n; i++) {
    long long x, v;
    cin >> x >> v;
    sushi.push_back({x, v});
  }
  sushi.push_back({c, 0});
  vector<long long> c_sumLeft(n + 1);
  for (int i = 1; i <= n; i++) {
    c_sumLeft[i] =
        c_sumLeft[i - 1] + sushi[i][1] - (sushi[i][0] - sushi[i - 1][0]);
  }
  vector<long long> c_sumRight(n + 1);
  for (int i = 1; i <= n; i++) {
    c_sumRight[i] = c_sumRight[i - 1] + sushi[n - i + 1][1] -
                    (sushi[n - i + 2][0] - sushi[n - i + 1][0]);
  }
  long long ret = 0;
  for (int left = 0; left <= n; left++) {
    for (int right = 0; left + right <= n; right++) {
      long long now = c_sumLeft[left] + c_sumRight[right];
      now -= min(sushi[left][0], c - sushi[n - right + 1][0]);
      ret = max(ret, now);
    }
  }
  cout << ret << endl;
  return 0;
}
