#include <fstream>
#include <algorithm>

#define ll long long
using namespace std;

struct eff
{
	ll n, k;
	bool operator <(const eff& y)
	{
		return k > y.k;
	}
};

int main()
{
	ifstream cin("castle.in");
	ofstream cout("castle.out");
	ll n, s, *a, *k, i, b = 0;
	cin >> n >> s;
	a = new ll[n];
	k = new ll[n];
	for (i = 0; i < n; ++i)
		cin >> a[i] >> k[i];
	eff *e;
	e = new eff[2 * n];
	for (i = 0; i < n; ++i)
	{
		(e + 2 * i)->n = a[i] / k[i];
		(e + 2 * i)->k = k[i];
		(e + 2 * i + 1)->n = 1;
		(e + 2 * i + 1)->k = a[i] % k[i];
	}
	sort(e, e + 2 * n);
	for (i = 0; i < (2 * n); ++i)
	{
		if ((e + i)->n > s)
		{
			b += (e + i)->k * ((e + i)->n - s);
			s = 0;
		}
		else
			s -= (e + i)->n;
	}
	cout << b << endl;
	return 0;
}