#include <bits/stdc++.h>
using namespace std;
int n;
long long rod;
struct Sushi {
  long long pos, val;
} poi[int(1e5) + 5];
long long a[int(1e5) + 5], b[int(1e5) + 5];
int main() {
  scanf("%d%lld", &n, &rod);
  for (int i = 1; i <= n; i++) scanf("%lld%lld", &poi[i].pos, &poi[i].val);
  poi[n + 1].pos = rod;
  poi[n + 1].val = 0;
  for (int i = 0; i < n; i++)
    a[i] = a[i - 1] - (poi[i].pos - poi[i - 1].pos) + poi[i].val;
  for (int i = n; i >= 1; i--)
    b[i] = b[i + 1] - (poi[i + 1].pos - poi[i].pos) + poi[i].val;
  for (int i = 2; i <= n; i++) a[i] = max(a[i], a[i - 1]);
  for (int i = n - 1; i >= 1; i--) b[i] = max(b[i], b[i + 1]);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = max(ans, max(a[i], b[i]));
    ans = max(ans, max(a[i] - poi[i].pos + b[i + 1],
                       b[i] - (rod - poi[i].pos) + a[i - 1]));
  }
  printf("%lld\n", ans);
  return 0;
}
