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

using namespace std;

typedef long long ll;

#define size(s) (ll) (s).size()
#define all(s) (s).begin(), (s).end()
#define rall(s) (s).rbegin(), (s).rend()

int main() {
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	ll n, s, sum = 0;
	cin >> n >> s;
	vector<ll> a(n), k(n), used(n, 0);
	set<pair<int, int> > q;
	for (ll i = 0; i < n; i++) {
		cin >> a[i] >> k[i];
		sum += a[i];
		q.insert({-k[i], i});
	}
	while (!q.empty() && s > 0) {
		int id = q.begin()->second;
		q.erase(q.begin());
		if (used[id] == 0) {
			sum -= min(a[id] / k[id], s) * k[id];
			s -= min(a[id] / k[id], s);
			used[id] = 1;
			if (a[id] % k[id] > 0) {
				q.insert({-(a[id] % k[id]), id});
			}
		} else {
			sum -= a[id] % k[id];
			s -= 1;
		}
	}
	cout << sum << '\n';
    return 0;
}

