#include<bits/stdc++.h>
#define maxn 100886
using namespace std;
int n, c; 
int w[maxn], v[maxn];
int a[maxn];
int maxx = -10865852;
inline int read() {
	int x = 0, y = 1;
	char ch = getchar();
	while(!isdigit(ch)) {
		if(ch == '-') y = -1;
		ch = getchar();
	}
	while(isdigit(ch)) {
		x = (x << 1) + (x << 3) + ch - '0';
		ch = getchar();
	}
	return x * y;
}
int main() {
	n = read(), c = read();
	for(int i = 1; i <= n; ++i) 
		w[i] = read(), v[i] = read();
	for(int i = 1; i <= n; ++i) {
		if(i == 1) {
			a[i] = 0 - w[i] + v[i];
		}
		a[i] = a[i - 1] + v[i] - (w[i] - w[i - 1]);
		maxx = max(a[i], maxx);
	}
	cout << maxx <<'\n';
	return 0;
}