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

using namespace std;

int main(){
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	int n, s;
	cin >> n >> s;
	vector< pair<int, int> > arr(2 * n);
	for (int i = 0; i < n; i++) {
		int a, k;
		cin >> a >> k;
		if (a / k != 0) { arr[i].first = k; arr[i].second = a / k; }
		arr[n + i].first = a % k; arr[n + i].second = 1;
	}
	sort(arr.begin(), arr.end());
	int j = 2 * n - 1;
	while (s > 0 && j >= 0) {
		while (s > 0 && arr[j].second > 0) {
			s--;
			arr[j].second--;
		}
		j--;
	}
	long long ans = 0;
	for (int i = 0; i < 2 * n; i++) {
		ans += arr[i].second * arr[i].first;
	}
	cout << ans;
	return 0;
}