#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-5;
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const int dir[4][2] = {1, 0, -1, 0, 0, 1, 0, -1};
long long x[N], v[N];
int main() {
  long long n, c;
  while (cin >> n >> c) {
    int cnt = -1;
    for (int i = 0; i < n; i++) {
      long long xx, val;
      cin >> xx >> val;
      if (!i) {
        if (xx < val) {
          x[++cnt] = xx;
          v[cnt] = val;
        }
      } else {
        if (xx - x[cnt] <= val) {
          x[++cnt] = xx;
          v[cnt] = val;
        }
      }
    }
    long long ans = 0;
    long long dis = 0;
    for (int i = 0; i <= cnt; i++) {
      if (cnt == -1) break;
      ans += v[i];
      int tmp = x[i] - dis;
      int tmp2 = c - x[i] + dis;
      int minx = min(tmp, tmp2);
      ans -= minx;
      dis = x[i];
    }
    cout << ans << endl;
  }
  return 0;
}
