#include <bits/stdc++.h>
using namespace std;
int main(void) {
  unsigned long n, c;
  cin >> n >> c;
  vector<array<unsigned long, 2>> sushi(n);
  for (int i = 0; i < n; i++) {
    cin >> sushi[i][0] >> sushi[i][1];
  }
  unsigned long score = 0, buf = 0, bufR = 0;
  for (int i = 0; i < n; i++) {
    if (i == 0) {
      buf += sushi[i][1] - sushi[i][0];
    } else {
      buf += sushi[i][1] - sushi[i][0] + sushi[i - 1][0];
    }
    score = max(score, buf);
    bufR = 0;
    for (int j = n - 1; j > i; j--) {
      if (j == n - 1) {
        bufR += sushi[j][1] - (c - sushi[j][0]);
      } else {
        bufR += sushi[j][1] - (sushi[j + 1][0] - sushi[j][0]);
      }
      score = max(score, buf + bufR - sushi[i][0]);
    }
  }
  buf = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      buf += sushi[i][1] - (c - sushi[i][0]);
    } else {
      buf += sushi[i][1] - (sushi[i + 1][0] - sushi[i][0]);
    }
    score = max(score, buf);
    bufR = 0;
    for (int j = 0; j > i; j++) {
      if (j == 0) {
        bufR += sushi[j][1] - sushi[j][0];
      } else {
        bufR += sushi[j][1] - sushi[j][0] + sushi[j - 1][0];
      }
      score = max(score, buf + bufR - (c - sushi[i][0]));
    }
  }
  cout << score;
  return 0;
}
