#include <iostream>
#include <algorithm>
using namespace std;


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

int main()
{
	ll n, s;
	cin >> n >> s;
	
	vector<pair<int, int> > x;
	
	ll total = 0;
	vector<int> zz;
	for (ll i = 0; i < n; ++i)
	{
		ll q, w;
		cin >> q >> w;
		x.pb(mp(w, q));
		total += (q + w - 1) / w; // Ceil
	}
	
	sort(x.begin(), x.end());
	for (auto w : x)
	{
		zz.pb((w.second + w.first - 1) / w.first);
	}
	auto g = zz.begin();
	
	vector<ll> ans(n, 0);
	
	while (total > s)
	{
		while (*g == 0)
			++g;
		(*g)--;
		total--;
		auto t = x[g - zz.begin()];
		ans[g - zz.begin()] = t.second - t.first * (*g);
	}
	
	ll out = 0;
	
	for (ll r : ans)
	{
		out += r;
	}
	
	cout << out;
	
	return 0;
}
