#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <stdio.h>
#include <cmath>

using namespace std;

const long long N = 100000;
struct zab {
	long long a;
	long long k;
};
zab stena[N];
bool sort1(zab a, zab b) {
	return a.k > b.k;
}
bool sort2(zab a, zab b) {
	return a.a > b.a;
}

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	long long n, s;
	cin >> n >> s;
	for (long long i = 0; i < n; i++) {
		cin >> stena[i].a >> stena[i].k;
	}
	sort(stena, stena + n, sort1);
	long long res = 0;
	for (long long i = 0; i < n; i++) {
		if (s >= stena[i].a / stena[i].k) {
			s = s - stena[i].a / stena[i].k;
			stena[i].a = stena[i].a % stena[i].k;
		}
		else {
			stena[i].a = stena[i].a - s * stena[i].k;
			s = 0;
		}
		res = res + stena[i].a;
	}
	sort(stena, stena + n, sort2);
	for (long long i = 0; i < n; i++) {
		if (s > 0) {
			res = res - stena[i].a;
			s--;
			stena[i].a = 0;
		}
	}
	cout << res << endl;
	//for (;;);
}