#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

const int sz = 1e5;

struct wall {
	long long a, k;
};

wall ar[sz];

bool comp(wall a, wall b) {
	return a.k > b.k;
}

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	int n, s;
	scanf("%d%d", &n, &s);
	long long sum = 0;
	for (int i = 0; i < n; i++) {
		scanf("%lld%lld", &ar[i].a, &ar[i].k);
		sum += ar[i].a;
	}
	sort(ar, ar + n, comp);
	for (int i = 0; s > 0 && i < n; i++) {
		if (s < ar[i].a / ar[i].k) {
			sum -= s * ar[i].k;
			ar[i].a -= s * ar[i].k;
			s = 0;
		}
		else {
			sum -= (ar[i].a / ar[i].k) * ar[i].k;
			s -= ar[i].a / ar[i].k;
			ar[i].a -= (ar[i].a / ar[i].k) * ar[i].k;
		}
	}
	for (int i = 0; i < n && s > 0; i++) {
		if (ar[i].a > 0) {
			s--;
			sum -= ar[i].a;
		}
	}
	printf("%lld", sum);
	return 0;
}

