#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long int n, c;
  cin >> n >> c;
  vector<long long int> x(n + 2), v(n + 1);
  for (int i = 1; i < n + 1; i++) {
    cin >> x[i] >> v[i];
  }
  x[0] = 0;
  v[0] = 0;
  x[n + 1] = c;
  long long int m = 0;
  long long int sum = 0;
  for (int i = 1; i < n + 1; i++) {
    sum = sum + v[i] - (x[i] - x[i - 1]);
    m = max(m, sum);
  }
  sum = 0;
  for (int i = n; i >= 1; i--) {
    sum = sum + v[i] - (x[i + 1] - x[i]);
    m = max(m, sum);
  }
  for (int i = 1; i < n + 1; i++) {
    sum = 0;
    for (int j = 1; j <= i; j++) {
      sum = sum + v[j] - (x[j] - x[j - 1]);
    }
    sum = sum - x[i];
    for (int j = n; j > i; j--) {
      sum = sum + v[j] - (x[j + 1] - x[j]);
      m = max(m, sum);
    }
  }
  for (int i = 1; i < n + 1; i++) {
    sum = 0;
    for (int j = n; j >= i; j--) {
      sum = sum + v[j] - (x[j + 1] - x[j]);
    }
    sum = sum - (c - x[i]);
    for (int j = 1; j < i; j++) {
      sum = sum + v[j] - (x[j] - x[j - 1]);
      m = max(m, sum);
    }
  }
  cout << m << endl;
}
