#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, c, x, y, now = 0;
  long long s = 0, maxx = 0;
  scanf("%d %d", &n, &c);
  for (i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    s += y - x + now;
    maxx = max(s, maxx);
    now = x;
  }
  printf("%lld", maxx);
  return 0;
}
