t['~~'];n,i,s;c(int*x){i=x[1]-1[&x][1];}main(m){for(;i=scanf("%d%d",&n,&m)*n;printf("%d\n",s)){for(s=0;i;scanf("%d%d",t+i,t-~i))i-=2;qsort(t,n,8,c);for(n*=2;n;i<m?m-=i:(s+=t[1]*(i-m),m=0))i=t[n-=2];}}