#include <iostream>
#include <fstream>
#include <vector>
#include <map>
using namespace std;
ifstream in("castle.in");
ofstream out("castle.out");
int main()
{
	int n, s;
	in >> n >> s;
	map<int, long long> p;
	for (int i = 0; i < n; ++i) {
		int a, k;
		in >> a >> k;
		p[k] += a / k;
		p[a % k]++;
	}
	long long r = 0;
	for (auto i = p.rbegin(); i != p.rend(); ++i) {
		if (s == 0)
			r += (long long)(i->second) * i->first;
		else if (s >= i->second) {
			s -= i->second;
		}
		else {
			r += (long long)(i->second - s) * i->first;
			s = 0;
		}
	}
	out << r;
}