#include<bits/stdc++.h>
using namespace std;
int n,ll,now,ans,len,l,r;
struct note{
int x,y;
}a[20000];
bool cmp(note x,note y){
if(x.x==x.y)
return x.y<y.y;
return x.x<y.x;
}
int main(){
scanf("%d%d",&n,&ll);
for(int i=1;i<=n;i++){
scanf("%d%d",&a[i].x,&a[i].y);
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=n;i++){
int o=0;
now=max(now,a[i].x);
if((a[i].y-now)%ll!=0){
o++;
}
o+=(a[i].y-now)/ll;
if(o<=0){
continue;
}
//printf("%d\n",o);
now+=o*ll;
ans+=o;
}
printf("%d",ans);
return 0;
}
WA六个点 看不出哪里有问题