#include <bits/stdc++.h>
using namespace std;
long xv[100000][2] = {};
int main(void) {
  int n, c;
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> xv[i][0] >> xv[i][1];
  }
  int p = 0;
  int cal = 0;
  int iflag = 0;
  for (int i = 0; i < n; i++) {
    if (xv[i][1] >= xv[i][0] - p) {
      if (iflag != i - 1) {
        for (int k = iflag + 1; k < i; k++) {
          cal += xv[k][1];
        }
      }
      p = xv[i][0];
      cal += xv[i][0] - p + xv[i][1];
      iflag = i;
    }
  }
  cout << cal << endl;
  return 0;
}
