#include<stdio.h>
#include<algorithm>
struct ss
{
int day;
int cap;
};
struct cc
{
bool operator()(struct ss ob1,struct ss ob2)
{
return ob1.day>ob2.day;
}
}comp;
int main()
{
int n,c,ct=0,val,j,it,i,flag=0;
int cap;
int arr[100009];
int maxi=-1e9;
int day[100009];
struct ss st[100009];
scanf("%d%d",&n,&cap);
for(i=0;i<n;i++)
{
scanf("%d%d",&st[i].day,&st[i].cap);
day[st[i].day]=st[i].cap;
if(st[i].day>maxi)
maxi=st[i].day;
}
int s=0;
for(i=1;i<=maxi+1;i++)
{
//printf("day[i-1]=%d day[i]=%d\n",day[i-1],day[i]);
if(cap>day[i-1])
{
if(day[i]>cap-day[i-1])
{
day[i]=day[i]-(cap-day[i-1]);
s+=cap;
}
else
{
s+=day[i-1]+day[i];
day[i]=0;
}
day[i-1]=0;
// printf("up day[i]=%d i=%d\n",day[i],i);
// printf("i=%d day[i]=%d cap-day[i-1]=%d\n",i,day[i],cap-day[i-1]);
}
else
{
if(day[i-1]>cap)
{
s+=cap;
day[i-1]=day[i-1]-cap;
}
else
{
s+=day[i-1];
day[i-1]=0;
}
//day[i]+=day[i-1];
}
//printf("i=%d s=%d\n",i,s);
//printf("dwn day[i-1]=%d day[i]=%d i=%d\n",day[i-1],day[i],i);
}
printf("%d\n",s);
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8YWxnb3JpdGhtPgpzdHJ1Y3Qgc3MKewppbnQgZGF5OwppbnQgY2FwOwp9OwpzdHJ1Y3QgY2MKewpib29sIG9wZXJhdG9yKCkoc3RydWN0IHNzIG9iMSxzdHJ1Y3Qgc3Mgb2IyKQp7CnJldHVybiBvYjEuZGF5Pm9iMi5kYXk7Cn0KfWNvbXA7CmludCBtYWluKCkKewppbnQgbixjLGN0PTAsdmFsLGosaXQsaSxmbGFnPTA7CmludCBjYXA7CmludCBhcnJbMTAwMDA5XTsKaW50IG1heGk9LTFlOTsKaW50IGRheVsxMDAwMDldOwpzdHJ1Y3Qgc3Mgc3RbMTAwMDA5XTsKc2NhbmYoIiVkJWQiLCZuLCZjYXApOwpmb3IoaT0wO2k8bjtpKyspCnsKc2NhbmYoIiVkJWQiLCZzdFtpXS5kYXksJnN0W2ldLmNhcCk7CmRheVtzdFtpXS5kYXldPXN0W2ldLmNhcDsKaWYoc3RbaV0uZGF5Pm1heGkpCm1heGk9c3RbaV0uZGF5Owp9CmludCBzPTA7CmZvcihpPTE7aTw9bWF4aSsxO2krKykKewovL3ByaW50ZigiZGF5W2ktMV09JWQgZGF5W2ldPSVkXG4iLGRheVtpLTFdLGRheVtpXSk7CiAgICAgICAgaWYoY2FwPmRheVtpLTFdKQogICAgICAgIHsKICAgICAgICBpZihkYXlbaV0+Y2FwLWRheVtpLTFdKQogICAgICAgIHsKICAgICAgICBkYXlbaV09ZGF5W2ldLShjYXAtZGF5W2ktMV0pOwogICAgICAgIHMrPWNhcDsKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICBzKz1kYXlbaS0xXStkYXlbaV07CiAgICAgICAgZGF5W2ldPTA7CiAgICAgICAgCiAgICAgICAgfQogICAgICAgIGRheVtpLTFdPTA7CiAgICAgLy8gICBwcmludGYoInVwIGRheVtpXT0lZCBpPSVkXG4iLGRheVtpXSxpKTsKICAgICAgICAKICAgICAgLy8gIHByaW50ZigiaT0lZCBkYXlbaV09JWQgY2FwLWRheVtpLTFdPSVkXG4iLGksZGF5W2ldLGNhcC1kYXlbaS0xXSk7CiAgCiAgICAgICAgICAgICAgIAogICAgICAgIH0KICAgICAgICBlbHNlCiAgICAgICAgewogICAgICAgIGlmKGRheVtpLTFdPmNhcCkKICAgICAgICB7CiAgICAgICAgcys9Y2FwOwogICAgICAgIGRheVtpLTFdPWRheVtpLTFdLWNhcDsKICAgICAgICAKICAgICAgICB9CiAgICAgICAgZWxzZQogICAgICAgIHsKICAgICAgICBzKz1kYXlbaS0xXTsKICAgICAgICBkYXlbaS0xXT0wOwogICAgICAgIAogICAgICAgIH0KICAgICAgICAvL2RheVtpXSs9ZGF5W2ktMV07CiAgICAgICAgCiAgICAgICAgfQogICAgICAgIC8vcHJpbnRmKCJpPSVkIHM9JWRcbiIsaSxzKTsKICAgICAgICAvL3ByaW50ZigiZHduIGRheVtpLTFdPSVkIGRheVtpXT0lZCBpPSVkXG4iLGRheVtpLTFdLGRheVtpXSxpKTsKfQpwcmludGYoIiVkXG4iLHMpOwogICAgICAgIHJldHVybiAwOwogICAgICAgIH0=