#include <iostream>
#include <algorithm>
using namespace std;
const int N=3e5+1;
int a[N];
int main() {
long long n,d;
cin>>n>>d;
int mn=N;
for(int i=0;i<n*2;i++){
cin>>a[i];
mn=min(mn,a[i]);
}
int max=0,sum=0;
for(int i=0;i<n*2;i+=2){
if((a[i]+a[i+1])<min(a[i],a[i+1])+mn+d)sum+=a[i]+a[i+1];
else sum+=min(a[i],a[i+1])+mn+d;
}
cout<<sum;
}