#include<fstream>
#include<algorithm>
#include<set>

using namespace std;

typedef long long ll;
const int maxn = 100005;

int n;
ll s;

multiset<pair<pair<ll, ll>, int>> mys;

int main() {
	ifstream cin("castle.in");
	ofstream cout("castle.out");
	ios_base::sync_with_stdio(false);
	cin >> n >> s;
	for (int i = 1; i <= n; ++i) {
		pair<pair<ll, ll>, int> a;
		cin >> a.first.first >> a.first.second;
		a.second = i;
		mys.insert(a);
	}
	while (s > 0 && mys.size() > 0) {
		pair<pair<ll, ll>, int> a = (*mys.rbegin());
		if (a.first.first - a.first.second >= 0) {
			ll k = a.first.first / a.first.second;
			k = min(k, s);
			mys.erase(a);
			a.first.first -= k*a.first.second;
			if (a.first.first > 0) {
				mys.insert(a);
			}
			s -= k;
		}
		else {
			mys.erase(a);
			s -= 1;
		}
	}
	ll ans = 0;
	for (auto it = mys.begin(); it != mys.end(); ++it) {
		ans += (*it).first.first;
	}
	cout << ans;
	return 0;
}