N, C = map(int, raw_input().split())
a = []
d = []
A = []
AA = []
next = 0
prev = N-1
for i in range(N):
	x, v = map(int, raw_input().split())
	a.append(x, C-x, v)
	d.append([])
	p.append([])
d[0] = a[0][2] - a[0][0]
d[N-1] = a[N-1][2] - a[N-1][1]
A.append(0)
A.append(N-1)
AA.append(d[0])
AA.append(d[N-1])
while(true):
	c = A[AA.index(max(AA))]
	if c == 0:
		next = 1
		prev = N - 1
	elif c == N-1:
		next = 0
		prev = N - 2
	else:
		next = c + 1
		prev = c - 1
	if d[next] == []:
		d[next] = d[c] + a[next][2] - a[next][0]
		A.append(next)
		AA.append(d[next])
	elif d[next] < d[c] + a[next][2] - a[next][0]:
		d[next] = d[c] + a[next][2] - a[next][0]
	if d[prev] == []:
		d[prev] = d[c] + a[prev][2] - a[prev][1]
		A.append(prev)
		AA.append(d[prev])
	elif d[prev] < d[prev] + a[prev][2] - a[prev][1]:
		d[prev] = d[c] + a[prev][2] - a[prev][1]
	if next == prev:
		print max(d)