#include<bits/stdc++.h>
#define LL long long
#define max(x,y) (x>y?x:y)
using namespace std;
const int maxn=1e5+9;
LL c,ans,n;
LL x[maxn],v[maxn],dis[maxn],f[maxn],f_[maxn];
LL read(){
	LL x=0;bool f=0;char c=getchar();
	while (c<'0'||c>'9'){if (c=='-') f=1;c=getchar();}
	while (c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return f?-x:x;
}
int main(){
	n=read(),c=read();
	for (int i=1;i<=n;++i) x[i]=read(),v[i]=read();
	f_[1]=v[1]-x[1];
	for (int i=2;i<=n;++i) f_[i]=f_[i-1]+v[i]-(x[i]-x[i-1]);
	for (int i=2;i<=n;++i) f_[i]=max(f_[i-1],f_[i]);//f_[i]表示正着最远走到i最多可以得到多少体力值 
	f[n]=v[n]-(c-x[n]);
	for (int i=n-1;i>=1;--i) f[i]=f[i+1]+v[i]-(x[i+1]-x[i]);
	for (int i=n-1;i>=1;--i) f[i]=max(f[i+1],f[i]);//f[i]表示反着走最远走到i最多可以得到多少体力值 
	for (int i=1;i<=n;++i) ans=max(ans,max(max(f_[i],0),max(f[i+1],0)));
	cout<<ans<<endl;
	return 0;
}
