#include <cstdio>
int n;
long long C;
struct cake{
	long long x, v;
} s[100002];
long long max(long long a, long long b){
	return (a > b) ? a : b;
}
int main()
{
	scanf("%d %d", &n, &C);
	int i, l = 1, r = n;
	for (i = 1; i <= n; i++)
		scanf("%d %d", &s[i].x, &s[i].v);
	s[n + 1].x = C + 1;
	long long ans = 0, left[100002] = {}, right[100002] = {};
	for (i = 1; i <= n; i++) {
		int k = n - i + 1;
		left[i] = max(left[i - 1] + s[i].v - (s[i].x - s[i - 1].x), left[i]);
		right[k] = max(right[k + 1] + s[k].v - (s[k + 1].x - s[k].x), right[k]);
	}
	for (i = 1; i <= n; i++)
		ans = max(ans, max(left[i], right[i]));
	printf("%I64d\n", ans);
	return 0;
}