#include <bits/stdc++.h>
long x[100000];
long v[100000];
long leftw[100000];
long rightw[100000];
int main(void) {
  long n, c;
  scanf("%ld %ld\n", &n, &c);
  long max_cal = 0;
  {
    long now_cal = 0;
    long pos = 0;
    for (long i = 0; i < n; i++) {
      scanf("%ld %ld\n", x + i, v + i);
      now_cal += v[i] - x[i] + pos;
      pos = x[i];
      leftw[i] = now_cal;
      max_cal = (now_cal) > max_cal ? (now_cal) : max_cal;
    }
  }
  {
    long now_cal = 0;
    long pos = c;
    for (long i = n - 1; i >= 0; i--) {
      now_cal += v[i] - pos + x[i];
      pos = x[i];
      rightw[i] = now_cal;
      max_cal = (now_cal) > max_cal ? (now_cal) : max_cal;
    }
  }
  for (long i = 0; i < n; i++) {
    {
      long now_cal = rightw[i] - c + x[i];
      for (long j = 0; j < i; j++) {
        max_cal =
            (now_cal + leftw[j]) > max_cal ? (now_cal + leftw[j]) : max_cal;
      }
    }
    {
      long now_cal = leftw[i] - x[i];
      for (long j = i + 1; j < n; j++) {
        max_cal =
            (now_cal + rightw[j]) > max_cal ? (now_cal + rightw[j]) : max_cal;
      }
    }
  }
  printf("%ld\n", max_cal);
  return 0;
}
