#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>

using namespace std;

#define lint long long int

bool cmp(pair<lint, lint> a, pair<lint, lint> b)
{
	return a.second > b.second;
}

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);

	lint n, s;
	vector<pair<lint, lint>> v;

	cin >> n >> s;

	for (lint i = 0; i < n; i++)
	{
		lint a, b;
		cin >> a >> b;

		lint x = a / b;
		lint y = a % b;
		if(x != 0)
		v.push_back(make_pair(x * b, b));
		if(y != 0)
		v.push_back(make_pair(y, y));
	}

	sort(v.begin(), v.end(), cmp);

	lint curLeft = s;
	lint res = 0;
	for (lint i = 0; i < v.size(); i++)
	{
		lint x = v[i].first / v[i].second;
		x = min(x, curLeft);
		curLeft -= x;
		v[i].first -= v[i].second * x;
		res += v[i].first;
	}

	/*sort(v.begin(), v.end());
	llint res = 0;
	for (lint i = v.size() - 1; i >= 0; i--)
	{
		if (v[i].first <= 0)
			continue;
		lint x = min(1, v[i].first / v[i].second);
		x = min(x, curLeft);
		curLeft -= x;
		v[i].first -= x * v[i].second;
		res += max(0, v[i].first);
	}*/

	cout << res;

}