#include <bits/stdc++.h>
int main(void) {
  int n, where = 0;
  long long int x[100001], v[100001], cal_r = 0LL, cal_l = 0LL, cal_rl = 0LL,
                                      cal_l2 = 0LL, cal_r2 = 0LL, c;
  x[0] = 0LL;
  v[0] = 0LL;
  scanf("%d %lld", &n, &c);
  for (int i = 1; i <= n; i++) {
    scanf("%lld %lld", &x[i], &v[i]);
  }
  int rf = 0;
  int lf = 0;
  do {
    rf = 0;
    long long int total_cal = 0;
    for (int i = where + 1; i <= n; i++) {
      total_cal += v[i] - x[i] + x[i - 1];
      if (total_cal > 0) {
        rf = 1;
        where = i;
        cal_r += total_cal;
        break;
      }
    }
  } while (rf);
  x[n + 1] = c;
  where = n + 1;
  do {
    lf = 0;
    long long int total_cal = 0;
    for (int i = where - 1; i > 0; i--) {
      total_cal += v[i] + x[i] - x[i + 1];
      if (total_cal > 0) {
        lf = 1;
        where = i;
        cal_l += total_cal;
        break;
      }
    }
  } while (lf);
  long long int total_cal_rl = 0, best = 0;
  where = 0;
  for (int j = 1; j <= n; j++) {
    total_cal_rl = 0;
    where = 0;
    cal_l2 = 0;
    for (int i = where + 1; i <= j; i++) {
      total_cal_rl += v[i] - x[i] + x[i - 1];
    }
    total_cal_rl -= x[j];
    if (total_cal_rl < 0) continue;
    where = n + 1;
    long long int temp = 0;
    do {
      long long int total_cal = 0;
      lf = 0;
      for (int i = where - 1; i > j; i--) {
        total_cal += v[i] + x[i] - x[i + 1];
        if (total_cal > 0) {
          lf = 1;
          where = i;
          cal_l2 += total_cal;
          break;
        }
      }
    } while (lf);
    total_cal_rl += cal_l2;
    if (total_cal_rl > best) best = total_cal_rl;
  }
  long long int total_cal_lr = 0, best2 = 0;
  where = 0;
  for (int j = n; j > 0; j--) {
    total_cal_lr = 0;
    where = 0;
    cal_l2 = 0;
    for (int i = n; i >= j; i--) {
      total_cal_lr += v[i] + x[i] - x[i + 1];
    }
    total_cal_lr -= c - x[j];
    if (total_cal_lr < 0) continue;
    where = 0;
    long long int temp = 0;
    do {
      long long int total_cal = 0;
      rf = 0;
      for (int i = where + 1; i < j; i++) {
        total_cal += v[i] - x[i] + x[i - 1];
        if (total_cal > 0) {
          rf = 1;
          where = i;
          cal_l2 += total_cal;
          break;
        }
      }
    } while (rf);
    total_cal_lr += cal_l2;
    if (total_cal_lr > best2) best2 = total_cal_lr;
  }
  if (cal_r > cal_l && cal_r > best && cal_r > best2) {
    printf("%lld\n", cal_r);
  } else if (cal_l > best && cal_l > best2) {
    printf("%lld\n", cal_l);
  } else if (best > best2) {
    printf("%lld\n", best);
  } else {
    printf("%lld\n", best2);
  }
  return 0;
}
