#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

#define SIZE 100228
#define ll long long
#define pint pair<ll, ll>
#define mp make_pair

int n;
ll s;
ll a[SIZE], k[SIZE];
ll need[SIZE];
ll lft[SIZE];
multiset<pint> st;


int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s;
	ll taken = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> k[i];
		need[i] = a[i] / k[i];
		lft[i] = a[i] % k[i];
		if (lft[i] > 0)
			need[i]++;
		else
			lft[i] = k[i];
		taken += need[i];
		if (lft[i] == k[i])
			st.insert(mp(k[i], need[i]));
		else
		{
			st.insert(mp(lft[i], 1));
			st.insert(mp(k[i], a[i] / k[i]));
		}
	}
	ll ans = 0;
	ll diff = taken - s;
	while (diff > 0)
	{
		pint nw = *st.begin();
		st.erase(st.begin());
		if (nw.second < diff)
		{
			ans += nw.first * nw.second;
			diff -= nw.second;
		}
		else
		{
			ans += diff * nw.first;
			break;
		}
	}
	cout << ans << endl;
	return 0;

}