#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < n; i++)
#define sz(a) (int)a.size()
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

const int MAXN = 100500;
const string NAME = "castle";

pair <ll, ll> arr[MAXN];
ll need[MAXN];
ll cn;
set <pair <ll, ll> > pl;

ll n, s;
                  
vector < pair <ll, ll> > ev;

int main()
{
#ifndef LOCAL                                        
	freopen((NAME + ".in").c_str(), "rt", stdin);
	freopen((NAME + ".out").c_str(), "wt", stdout);
#endif	

	cin >> n >> s;

	forn(i, n)
	{
		ll k, a;
		cin >> a >> k;
		ev.pb(mp(k, a / k));
		cn += a / k;

		if (a % k != 0)
		{
			ev.pb(mp(a % k, 1));
			cn++;
		}	
	}
	
	sort(ev.begin(), ev.end());
	//reverse(ev.begin(), ev.end());
	ll res = 0;
                             

        forn(i, sz(ev))
	{
		if (cn > s)
		{
			ll cnt = min(cn - s, ev[i].second);

			cn -= cnt;                       
			res += cnt * ev[i].first;	
		}                      
	}
                                                 
        cout << res;

	

	return 0;
}