#include <bits/stdc++.h>
int main() {
  long long N;
  long long C;
  long long *x;
  long long *v;
  long long *c;
  long long saidai = 0;
  scanf("%d%d", &N, &C);
  x = new long long[N];
  v = new long long[N];
  c = new long long[N + 1];
  c[0] = 0;
  for (long long n = 0; n < N; n++) {
    scanf("%d%d", &x[n], v[n]);
    c[n + 1] = c[n] + v[n] - x[n];
  }
  for (long long n = 0; n < N + 1; n++) {
    saidai = saidai < c[n] ? c[n] : saidai;
  }
  printf("%d\n", saidai);
}
