// A.cpp : Defines the entry point for the console application.
//

#include <fstream>
#include <vector>
#include <set>

using namespace std;

int main()
{
	long long n, s, sum = 0, i, j, k;
	set<pair<long long, long long>> p;
	set<pair<long long, long long>>::iterator it;
	ifstream cin("castle.in");
	ofstream cout("castle.out");
	cin >> n >> s;
	for (i = 0; i < n; i++)
	{
		cin >> j >> k;
		sum += j;
		if (j / k)
		{
			it = p.upper_bound(make_pair(k, -1));
			if (it == p.end() || it->first != k)
			{
				p.insert(make_pair(k, j / k));
			}
			else
			{
				p.insert(make_pair(k, it->second + j / k));
				p.erase(it);
			}
		}

		if (j % k)
		{
			it = p.upper_bound(make_pair(j % k, -1));
			if (it == p.end() || it->first != j % k)
			{
				p.insert(make_pair(j % k, 1));
			}
			else
			{
				p.insert(make_pair(j % k, it->second + 1));
				p.erase(it);
			}
		}
	}

	while (s > 0 && p.size())
	{
		it = p.end();
		it--;
		if (it->second <= s)
		{
			sum -= it->first * it->second;
			s -= it->second;
			p.erase(it);
		}
		else
		{
			sum -= it->first * s;
			s = 0;
			p.erase(it);
		}
	}

	cout << sum << endl;
	cout.close();
}

