#include <bits/stdc++.h>
using namespace std;
int n;
long long x[100005], v[100005], c, Max, con;
template <typename Drake>
void read(Drake &x) {
  x = 0;
  char ch = getchar();
  bool f = 1;
  while (!isdigit(ch)) {
    if (ch == '-') f ^= 1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x *= (2 * f - 1);
}
template <typename Drake>
void write(Drake x) {
  if (x < 0) {
    x = -x;
    putchar('-');
  }
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
template <typename Drake>
void writeln(Drake x) {
  write(x);
  puts("");
}
void init() {
  read(n);
  read(c);
  for (register int i = 1; i <= n; i++) {
    read(x[i]);
    read(v[i]);
  }
}
int main() {
  init();
  x[0] = 0;
  long long l;
  l = 0;
  Max = 0;
  for (register int i = 0; i <= n; i++) {
    long long dis = x[max(0, i - 1)] + abs(c - x[n]);
    con = l + v[n] - dis;
    if (con > Max) Max = con;
    for (register int j = n - 1; j >= 1; j--) {
      con = v[j] - abs(x[j + 1] - x[j]);
      if (con > Max) Max = con;
    }
    l = l + v[i] - abs(x[i] - x[max(i - 1, 0)]);
    if (l > Max) Max = l;
  }
  l = 0;
  for (register int i = 1; i <= n - i; i++) {
    int t = x[i];
    x[i] = x[n - i];
    x[n - i] = t;
  }
  for (register int i = 1; i <= n - i; i++) {
    int t = v[i];
    v[i] = v[n - i];
    v[n - i] = t;
  }
  for (register int i = 0; i <= n; i++) {
    long long dis = x[max(0, i - 1)] + abs(c - x[n]);
    con = l + v[n] - dis;
    if (con > Max) Max = con;
    for (register int j = n - 1; j >= 1; j--) {
      con = v[j] - abs(x[j + 1] - x[j]);
      if (con > Max) Max = con;
    }
    l = l + v[i] - abs(x[i] - x[max(i - 1, 0)]);
    if (l > Max) Max = l;
  }
  cout << Max << endl;
  return 0;
}
