#include <iostream>
#include <algorithm>
using namespace std;
int a[100001], n, s;
pair<int, pair<int, int>> k[100001];
int main() {
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	cin >> n >> s;
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &a[i], &k[i].first);
		if (k[i].first > a[i]) k[i].first = a[i];
		else
			k[i].second.first = a[i] / k[i].first, k[i].second.second=a[i]%k[i].first;
		sum += a[i];
	}
	sort(k, k + n);
	for (int i = n - 1; i >= 0; i--) {
		if (s - k[i].second.first <= 0) {
			sum -= k[i].first*s;
			cout << sum;
			return 0;
		}
		s -= k[i].second.first;
		sum -= k[i].first*k[i].second.first;
		k[i].first = k[i].second.second;
		if (k[i].first) k[i].second.first = 1; else k[i].second.first = 0;
	}
	sort(k, k + n);
	for (int i = n - 1; i >= 0; i--) {
		if (s - k[i].second.first <= 0) {
			sum -= k[i].first*s;
			cout << sum;
			return 0;
		}
		s -= k[i].second.first;
		sum -= k[i].first*k[i].second.first;
		k[i].first = k[i].second.second;
	}
	cout << sum;
}