#include<cstdio>#include<cctype>template<classT>voidr(T &x){#define gc getchar()
x =0;int f =1;char c = gc;while(!isdigit(c)){if(c =='-') f =-1; c = gc;}while(isdigit(c)) x =(x <<3)+(x <<1)+(c ^48), c = gc;
x *= f;}voidopenfile(){
freopen ("tuna.in","r",stdin);
freopen ("tuna.out","w",stdout);}intMax(int x,int y){return x > y ? x : y;}intFabs(int x){return x >0? x :(~x)+1;}int n, ans, x;intmain(){///openfile();r(n);r(x);for(int i =1;i <= n; i++){int p1, p2;r(p1),r(p2);if(Fabs(p1 - p2)<= x)
ans +=Max(p1, p2);elser(p1), ans += p1;}
printf ("%d", ans);return0;}