#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
using namespace std;
const long long mod = 1000000007;
struct SegmentTree {
 private:
  long long n;
  vector<long long> node;

 public:
  SegmentTree(vector<long long> v) {
    long long sz = v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, 0);
    for (long long i = 0; i < (long long)(sz); i++) node[i + n - 1] = v[i];
    for (long long i = (long long)(n - 2) - 1; i >= 0; i--)
      node[i] = max(node[2 * i + 1], node[2 * i + 2]);
  }
  void update(long long k, long long x) {
    k += n - 1;
    node[k] = x;
    while (k) {
      k = (k - 1) / 2;
      node[k] = max(node[2 * k + 1], node[2 * k + 2]);
    }
  }
  long long getmax(long long a, long long b, long long k = 0, long long l = 0,
                   long long r = -1) {
    if (r < 0) r = n;
    if (r <= a || b <= l) return 0;
    if (a <= l && r <= b) return node[k];
    return max(getmax(a, b, 2 * k + 1, l, (l + r) / 2),
               getmax(a, b, 2 * k + 2, (l + r) / 2, r));
  }
};
long long n, c, x, v;
vector<pair<long long, long long> > sushi;
vector<long long> cl, ccl;
signed main() {
  scanf("%lld", &(n));
  scanf("%lld", &(c));
  sushi.resize(n);
  cl.resize(n);
  ccl.resize(n);
  for (long long i = 0; i < (long long)(n); i++) {
    scanf("%lld", &(x));
    scanf("%lld", &(v));
    sushi[i] = make_pair((x), (v));
  }
  long long prev = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    cl[i] = sushi[i].second - (sushi[i].first - prev);
    prev = sushi[i].first;
  }
  prev = c;
  for (long long i = 0; i < (long long)(n); i++) {
    ccl[i] = sushi[n - 1 - i].second - (prev - sushi[n - 1 - i].first);
    prev = sushi[n - 1 - i].first;
  }
  vector<long long> ruicl(n + 1);
  for (long long i = (long long)(1); i < (n + 1); i++)
    ruicl[i] = ruicl[i - 1] + cl[i - 1];
  SegmentTree rc(ruicl);
  vector<long long> ruiccl(n + 1);
  for (long long i = (long long)(1); i < (n + 1); i++)
    ruiccl[i] = ruiccl[i - 1] + ccl[i - 1];
  SegmentTree rcc(ruiccl);
  long long ret = 0;
  for (long long i = 0; i < (long long)(n + 1); i++) {
    ret = max(ret, ruicl[i] + max(0LL, rcc.getmax(0, n - i) -
                                           (i ? sushi[i - 1].first : 0)));
  }
  for (long long i = 0; i < (long long)(n + 1); i++) {
    ret = max(ret, ruiccl[i] + max(0LL, rc.getmax(0, n - i) -
                                            (i ? c - sushi[n - i].first : 0)));
  }
  cout << ret << endl;
}
