#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX = 1e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
int N;
ll C;
ll x[MAX], v[MAX];
int main() {
  cin >> N >> C;
  for (int i = 0; i < N; i++) scanf("%lld %lld", x + i, v + i);
  ll ans = 0;
  ll maxi, cur;
  for (int i = 0; i < N; i++) {
    maxi = cur = 0;
    for (int j = 0; j <= i; j++) {
      if (x[j] - cur > v[j]) {
        ans = max(ans, maxi);
        maxi -= (x[j] - cur) - v[j];
      } else {
        maxi += v[j] - (x[j] - cur);
        ans = max(ans, maxi);
      }
      cur = x[j];
    }
    if (i == N - 1) break;
    if (C - x[N - 1] + cur < v[N - 1]) {
      maxi += v[N - 1] - (C - x[N - 1] + cur);
      ans = max(ans, maxi);
    } else {
      ans = max(ans, maxi);
      maxi -= (C - x[N - 1] + cur) - v[N - 1];
    }
    cur = x[N - 1];
    for (int j = N - 2; j > i; j--) {
      if (cur - x[j] > v[j]) {
        ans = max(ans, maxi);
        maxi -= (cur - x[j]) - v[j];
      } else {
        maxi += v[j] - (cur - x[j]);
        ans = max(ans, maxi);
      }
      cur = x[j];
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    maxi = 0;
    cur = C;
    for (int j = N - 1; j >= i; j--) {
      if (cur - x[j] > v[j]) {
        ans = max(ans, maxi);
        maxi -= (cur - x[j]) - v[j];
      } else {
        maxi += v[j] - (cur - x[j]);
        ans = max(ans, maxi);
      }
      cur = x[j];
    }
    if (i == 0) break;
    if (C - cur + x[0] < v[0]) {
      maxi += v[0] - (C - cur + x[0]);
      ans = max(ans, maxi);
    } else {
      ans = max(ans, maxi);
      maxi -= (C - cur + x[0]) - v[0];
    }
    cur = x[0];
    for (int j = 1; j < i; j++) {
      if (x[j] - cur > v[j]) {
        ans = max(ans, maxi);
        maxi -= (x[j] - cur) - v[j];
      } else {
        maxi += v[j] - (x[j] - cur);
        ans = max(ans, maxi);
      }
      cur = x[j];
    }
  }
  cout << ans << endl;
}
