#include <fstream>
//#include <iostream>
#include <set>

using namespace std;

ifstream cin("castle.in");
ofstream cout("castle.out");

struct seg {
	int a, k;
};

int min(int a, int b) {
	return a < b ? a : b;
}

bool operator< (seg l, seg r) {
	return min(l.a, l.k) > min(r.a, r.k);
}

const int MAXN = 1e5;
int n;
long long s;
multiset <seg> f;

int main() {
	cin >> n >> s;
	for (int i = 0; i < n; ++i) {
		seg t;
		cin >> t.a >> t.k;
		f.insert(t);
	}
	while (f.size() > 0 && s > 0) {
		seg top = *f.begin();
		f.erase(f.begin());
		if (top.a < top.k) {
			--s;
			continue;
		}
		if (top.k * s < top.a) {
			top.a -= top.k * s;
			f.insert(top);
			s = 0;
			continue;
		}
		s -= top.a / top.k;
		top.a %= top.k;
		if (top.a > 0)
			f.insert(top);
	}
	long long ans = 0;
	for (multiset <seg>::iterator it = f.begin(); it != f.end(); ++it)
		ans += it->a;
	cout << ans << endl;
	//cin >> n;
	return 0;
}