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

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

using namespace std;

ifstream fin("castle.in");
ofstream fout("castle.out");

struct Cas
{
	int at, def, ones;
};

vector <Cas> all;
set <pair <int, Cas> > opt;
//vector <int> atak, def, one;
int n;
long long s;
long long res = 0;
long long ans = 0;

bool comp(Cas a, Cas b)
{
	return (a.at - (a.ones - 1) * a.def < b.at - (b.ones - 1) * b.def);
}

bool operator < (pair <int, Cas> a, pair <int, Cas> b)
{
	return (a.first < b.first || a.first == b.first && a.second.def < b.second.def);
}

int main()
{
	fin >> n >> s;

	/*atak.clear();
	atak.resize(n);
	def = atak;
	one = atak;*/

	all.clear();
	all.resize(n);

	for (int i = 0; i < n; i++)
	{
		fin >> all[i].at >> all[i].def;
		all[i].ones = (all[i].at + all[i].def - 1) / all[i].def;
		res += (long long)all[i].ones;
	}

	if (res <= s)
	{
		fout << 0;
		return 0;
	}

	for (int i = 0; i < n; i++)
	{
		opt.insert(make_pair(all[i].at - (all[i].ones - 1) * all[i].def, all[i]));
	}

	while (res > s)
	{
		auto mnv = *opt.begin();
		res--;
		mnv.second.ones--;
		ans += mnv.first;
		opt.erase(mnv);

		if (mnv.second.ones == 0)
			continue;
		if (mnv.first != mnv.second.def)
			mnv.first = mnv.second.def;
		opt.insert(mnv);
	}

	fout << ans;
	
	/*sort(all.begin(), all.end(), comp);

	long long cur = 0;

	for (int i = 0; i < n - 1; i++)
	{
		if (all[i].ones == 0)
			continue;
		while (res > s && all[i].ones > 0 && all[i].at - (all[i].ones - 1) * all[i].def <= all[i + 1].at - (all[i + 1].ones - 1) * all[i + 1].def)
		{
			res--;
			all[i].ones--;
		}
		cur = all[i].at - all[i].def * all[i].ones;
		if (cur > 0)
			ans += cur;
		if (res <= s)
			break;
	}

	if (res > s)
	{
		while (res > s)
		{
			res--;
			all[i].ones
		}
	}*/

	return 0;
}

