#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int n;
ull c;
std::vector<std::vector<double>> solve(std::vector<std::vector<ull>> x) {
  double nowcal = 0;
  std::vector<std::vector<double>> ret(x.size(), std::vector<double>(2, 0));
  for (size_t i = 1; i < x.size(); i++) {
    nowcal = nowcal + x[i][1] - (x[i][0] - x[i - 1][0]);
    ret[i][0] = nowcal;
    ret[i][1] = nowcal - x[i][0];
  }
  return ret;
}
int main(int argc, char const *argv[]) {
  std::cin >> n >> c;
  std::vector<std::vector<ull>> x(n + 1, std::vector<ull>(2, 0));
  std::vector<std::vector<ull>> y(n + 1, std::vector<ull>(2, 0));
  x[0][0] = x[0][1] = 0;
  y[0][0] = y[0][1] = 0;
  for (size_t i = 0; i < n; i++) {
    std::cin >> x[i + 1][0] >> x[i + 1][1];
    y[i + 1][0] = c - x[i + 1][0];
    y[i + 1][1] = x[i + 1][1];
  }
  sort(x.begin(), x.end());
  sort(y.begin(), y.end());
  std::vector<std::vector<double>> xx = solve(x);
  std::vector<std::vector<double>> yy = solve(y);
  double ans = 0;
  for (size_t i = 0; i < xx.size(); i++) {
    for (size_t j = 0; j < yy.size() - i; j++) {
      ans = max(ans, max(xx[i][0] + yy[j][1], yy[i][0] + xx[j][1]));
    }
  }
  std::cout << (ull)ans << '\n';
  return 0;
}
