#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

vector<pair<long long, long long> > pr;

int main()
{
	long long n, s;
	cin >> n >> s;

	for (int i = 0; i < n; i++)
	{
		long long a, k;
		cin >> a >> k;
		long long c = a / k;
		if (c != 0)
		{
			pr.push_back(make_pair(k, c));
		}
		if (a - c * k > 0)
		{
			pr.push_back(make_pair(a - c * k, 1));
		}
	}

	sort(pr.rbegin(), pr.rend());

	long long f = 0;

	for (int i = 0; i < pr.size(); i++)
	{
		long long delta = min(s, pr[i].second);
		pr[i].second -= delta;
		s -= delta;
		f += pr[i].first * pr[i].second;
	}

	cout << f;


	

    return 0;
}

