# coding: utf-8
# Your code here!
#N=int(input())
#a = list(map(int,input().split()))

#x = []
#y = []
#for i in range(5):
#    x1,y1=[int(i) for i in input().split()]
#    x.append(x1)
#    y.append(y1)

N,C=[int(i) for i in input().split()]

x = [0]
v = [0]
for i in range(N):
    x1,v1=[int(i) for i in input().split()]
    x.append(x1)
    v.append(v1)

x.append(C)
v.append(0)

s = [0]*(N+1)
g = [0]*(N+2)
m1=0;m2=0

for i in range(1,N+1):
    s[i] = s[i-1]+v[i]-(x[i]-x[i-1])

for i in reversed(range(1,N+1)):
    g[i] = g[i+1]+v[i]+(x[i]-x[i+1])

j=N+1
M=0
k=0
jj=j
for i in reversed(range(N+1)):
    val = s[i] + g[j] -min(k,x[i])
    while(jj-i>1):
#        print(jj)
        newval = s[i] + g[jj-1] -min(k+x[j]-x[jj-1],x[i])
        if newval >= val:
            val = newval
            jj=jj-1
            k+= x[j]-x[jj]
            j=jj
        else:
            jj=jj-1
#    print(i,j,val)
    M=max(M,val)

#print(s,g)
print(M)
            
        
        
    
    
    
    
    
    
    


















