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

using namespace std;

vector < pair <long long, long long> > a;
multiset <pair <long long, int> > 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()) {
			multiset <pair <long long, int> >::iterator y = q.end();
			y--;
			while (!q.empty() && (*y).first > 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), i});
	}
	if (!q.empty()) {
		multiset <pair <long long, int> >::iterator y = q.end();
		y--;
		while (!q.empty() && s) {
			s--;
			q.erase(*y);
			if (!q.empty()) {
				y = q.end();
				y--;
			}
		}
	}
	if (!q.empty()) {
		for (multiset <pair <long long, int> >::iterator i = q.begin(); i != q.end(); i++) {
			ans += (*i).first;
		}
	}
	cout << ans;
	return 0;
}