#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>;
#include <algorithm>;
#include <vector>;
using namespace std;
int n, s;
pair<int, int> arr[200001];
int main() {
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	scanf("%d%d", &n, &s);
	long long ans = 0;
	int count = 0;
	for (int i = 0; i < n; i++) {
		int a, k;
		scanf("%d%d", &a, &k);
		ans = ans + long long(a);
		if (a%k != 0) {
			arr[i + count] = make_pair(a - (a / k)*k, 1);
			count++;
		}
		arr[i+count] = make_pair(k, (a/k));
	}
	sort(arr, arr+n+count);
	for (int i = n + count - 1; i >= 0; i--) {
		if (s >= arr[i].second) {
			s -= arr[i].second;
			ans = ans - long long(arr[i].second * arr[i].first);
		}
		else if (s > 0) {
			ans = ans - long long(arr[i].first * s);
			s = 0;
			break;
		}
	}
	printf("%lld\n", ans);
	return 0;
}
