#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int M=100007;
int read(){
int ans=0,f=1,c=getchar();
while(c<‘0‘||c>‘9‘){if(c==‘-‘) f=-1; c=getchar();}
while(c>=‘0‘&&c<=‘9‘){ans=ans*10+(c-‘0‘); c=getchar();}
return ans*f;
}
int n,m,cnt,nl,nr,ans,sum;
struct node{
int l,r;
bool operator<(const node &x)const{return l<x.l;}
}e[M],q[M];
int cal(int x){return x?q[x].l-q[x-1].r:0;}
int main()
{
while(scanf("%d %d",&n,&m)==2){
for(int i=0;i<n;i++) e[i].l=read(),e[i].r=read()+1;
sort(e,e+n);
cnt=0; int ll=e[0].l,rr=e[0].r;
for(int i=1;i<n;i++){
if(e[i].r<=rr) continue;
if(e[i].l<=rr) rr=e[i].r;
else q[++cnt]=(node){ll,rr},ll=e[i].l,rr=e[i].r;
}
q[++cnt]=(node){ll,rr};
ans=0;
for(int i=0,j=0,cost=0;i<=cnt;i++){
int s=q[i].r-q[j].l;
cost+=cal(i);
while(cost>m){
j++;
s=q[i].r-q[j].l;
cost-=cal(j);
}
ans=max(ans,s-cost+m);
}printf("%d\n",ans);
}
return 0;
}