#include <bits/stdc++.h>
using namespace std;
const long long unsigned int MAXN = 101024;
long long unsigned int x[MAXN];
long long unsigned int v[MAXN];
int main() {
  long long unsigned int n, c;
  cin >> n >> c;
  x[0] = 0;
  v[0] = 0;
  x[n + 1] = c;
  v[n + 1] = 0;
  for (long long unsigned int i = 1; i <= n; ++i) {
    cin >> x[i] >> v[i];
  }
  long long unsigned int res = 0;
  long long unsigned int enep = 0;
  long long unsigned int enem = 0;
  for (long long unsigned int i = 1; i <= n; ++i) {
    enem += x[i] - x[i - 1];
    enep += v[i];
    if (enep > enem) res = max(res, enep - enem);
  }
  enep = 0;
  enem = 0;
  for (long long unsigned int i = n; i > 0; --i) {
    enem += x[i + 1] - x[i];
    enep += v[i];
    if (enep > enem) res = max(res, enep - enem);
  }
  for (long long unsigned int i = 1; i <= n; ++i) {
    enep = 0;
    enem = 0;
    for (long long unsigned int j = 1; j <= i; ++j) {
      enep += v[j];
    }
    enem += 2 * x[i];
    for (long long unsigned int j = n; j > i; --j) {
      enem += x[j + 1] - x[j];
      enep += v[j];
      if (enep > enem) res = max(res, enep - enem);
    }
    enep = 0;
    enem = 0;
    for (long long unsigned int j = i; j <= n; ++j) {
      enep += v[j];
    }
    enem += 2 * (x[n + 1] - x[i]);
    for (long long unsigned int j = 1; j < i; ++j) {
      enem += x[j] - x[j - 1];
      enep += v[j];
      if (enep > enem) res = max(res, enep - enem);
    }
  }
  cout << res << endl;
  return 0;
}
