#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <iostream>
#define ll long long int
using namespace std;
const int mod=1e9+7;


int main(){
#pragma comment(linker,"/STACK:536870912")
#pragma warning(disable:4996)
#ifdef _DEBUG
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
#else
	freopen("castle.in","rt",stdin);
	freopen("castle.out","wt",stdout);
#endif
	ll n,s,i,j,r,c,z;
	vector<ll> one(2,0),d;
	map<ll,ll> mp;
	map<ll,ll>::iterator it;
	scanf("%I64d%I64d",&n,&s);
	z=0;
	for(i=0;i<n;i++){
		scanf("%I64d%I64d",&one[1],&one[0]);
		mp[one[0]]+=one[1]/one[0];
		mp[one[1]%one[0]]+=1;
		z+=one[1];
	}
	it=mp.end();
	it--;
	for(;it!=mp.begin();it--){
		z-=it->first*min(it->second,s);
		s-=min(it->second,s);
	}
	printf("%I64d",z);


	return 0;
}