#include <bits/stdc++.h>
using namespace std;
long long a[100050] = {0}, b[100050] = {0};
long long dp1[100050] = {0}, dp2[100050] = {0};
int main() {
  int n, i;
  long long c, sum = 0, ans = 0, t;
  cin >> n >> c;
  for (i = 1; i <= n; i++) {
    scanf("%lld %lld", &b[i], &a[i]);
  }
  dp1[0] = 0;
  dp2[0] = -c;
  for (i = 1; i <= n; i++) {
    dp1[i] = dp1[i - 1] + a[i] - b[i] + b[i - 1];
    ans = max(ans, dp1[i]);
    dp2[i] = dp2[i - 1] + a[n - i + 1] + b[n - i + 1] - b[n - i + 2];
    ans = max(ans, dp2[i]);
  }
  for (i = 1; i < n; i++) {
    t = dp1[i] - b[i];
    if (t > 0) {
      for (int j = 1; j <= n - i; j++) {
        sum = t + dp2[j];
        ans = max(sum, ans);
      }
    }
  }
  for (i = 1; i < n; i++) {
    t = dp2[i] - c + b[n - i + 1];
    if (t > 0) {
      for (int j = 1; j <= n - i; j++) {
        sum = t + dp1[j];
        ans = max(sum, ans);
      }
    }
  }
  cout << ans << endl;
}
