#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long int N, C;
  long int maxr = -1, maxl = -1, maxr1[N + 1];
  cin >> N >> C;
  unsigned long int x[N + 2], v[N], sumr[N + 1], suml[N + 1];
  x[0] = 0;
  x[N + 1] = C;
  for (int i = 0; i < N; i++) {
    cin >> x[i + 1] >> v[i];
  }
  sumr[0] = 0;
  for (int i = 1; i <= N; i++) {
    sumr[i] = sumr[i - 1] + v[i - 1];
  }
  suml[0] = 0;
  for (int i = 1; i <= N; i++) {
    suml[i] = suml[i - 1] + v[N - i];
  }
  long int maxl1[N + 1];
  maxl1[0] = 0;
  for (int J = 1; J <= N; J++) {
    long int maxl0 = suml[J] - C + x[N + 1 - J];
    maxl1[J] = max(maxl1[J - 1], maxl0);
  }
  cout << "0" << endl;
}
