#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

vector < pair <long long, long long> > a;
multiset <long long> q;

int main() {
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	long long n, s;
	cin >> n >> s;
	a.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].second >> a[i].first;
	}
	sort(a.begin(), a.end());
	long long ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (!q.empty()) {
			set<long long>::iterator y = q.end();
			y--;
			while (!q.empty() && *y > a[i].first && s) {
				s--;
				q.erase(*y);
				y = q.end();
				y--;
			}
		}
		long long y = a[i].second / a[i].first;
		long long x = min(s, y);
		s -= x;
		q.insert(max((long long)0, a[i].second - x * a[i].first));
	}
	set<long long>::iterator y = q.end();
	y--;
	while (!q.empty() && s) {
		s--;
		q.erase(*y);
		y = q.end();
		y--;
	}
	for (set<long long>::iterator i = q.begin(); i != q.end(); i++) {
		ans += *i;
	}
	cout << ans;
	return 0;
}