//#define DEBUG

#ifdef DEBUG
#include <iostream>
#else
#include <fstream>
std::ifstream cin("castle.in");
std::ofstream cout("castle.out");
#endif
#include <algorithm>
using namespace std;


#define pb push_back 
#define mp make_pair 
typedef long long ll;

vector<pair<ll, ll> > x;
vector<ll> pr;
int main()
{
	ll n, s;
	cin >> n >> s;
	ll cu = 0;
	for (int i = 0; i < n; ++i)
	{
		ll a, b;
		cin >> a >> b;
		x.pb(mp(b, a / b));
		cu += a;
		if (a % b)
		{
			x.pb(mp(a % b, 1));
		}
	}
	sort(x.begin(), x.end());
	reverse(x.begin(), x.end());
	ll sum = 0;
	
	for (auto y : x)
	{
		if (s >= y.second)
		{
			s -= y.second;
			sum += y.first * y.second;
		}
		else
		{
			sum += y.first * s;
			break;
		}
	}
	cout << cu - sum << endl;
	return 0;
}
