#include <bits/stdc++.h>
using namespace std;
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chadd(T &a, T b) {
  a = a + b;
}
long long int dx[] = {0, 0, 1, -1};
long long int dy[] = {1, -1, 0, 0};
const long long INF = 1001001001001001LL;
const long long MOD = 1000000007LL;
long long int N, C, x[100010], v[100010];
long long int solve(long long int p, long long int q) {
  long long int ans = 0;
  set<pair<long long int, long long int> > cloc, anti;
  vector<pair<long long int, long long int> > rec_cloc(N), rec_anti(N);
  cloc.insert(make_pair(0, -1));
  anti.insert(make_pair(0, -1));
  long long int sum = 0, prev = 0;
  for (long long int(i) = (0); (i) < (N); (i)++) {
    sum += v[i] - p * (x[i] - prev);
    cloc.insert(make_pair(-sum, i));
    rec_cloc[i] = make_pair(-sum, i);
    prev = x[i];
  }
  sum = 0, prev = C;
  for (long long int(i) = (N - 1); (i) >= (0); (i)--) {
    sum += v[i] - q * (prev - x[i]);
    rec_anti[i] = make_pair(-sum, i);
    prev = x[i];
  }
  for (long long int(i) = (N - 1); (i) >= (0); (i)--) {
    pair<long long int, long long int> vl = *(cloc.begin());
    pair<long long int, long long int> vr = *(anti.begin());
    chmax(ans, -vl.first - vr.first);
    cloc.erase(rec_cloc[i]);
    anti.insert(rec_anti[i]);
  }
  return ans;
}
signed main() {
  cin >> N >> C;
  for (long long int(i) = (0); (i) < (N); (i)++) cin >> x[i] >> v[i];
  long long int ans = 0;
  chmax(ans, solve(1, 2));
  chmax(ans, solve(2, 1));
  cout << ans << endl;
  return 0;
}
