#include <iostream>
#include <fstream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
int main()
{
	ifstream in;
	ofstream out;
	in.open("castle.in");
	out.open("castle.out");
	int n, i, s, x, y, ans = 0;
	in >> n >> s;
	priority_queue<pair<int, int>, vector<pair<int, int> >, less<pair<int, int> > > a;
	for (i = 0; i < n; i++)
	{
		in >> x >> y;
		if(y > x) a.emplace(make_pair(x, x)); else
		a.emplace(make_pair(y, x));
		ans += x;
	}
	while (s > 0 && ans > 0)
	{
		x = a.top().second;
		y = a.top().first;
		if (x / y <= s)
		{
			ans -= (x / y) * y;
			s -= (x / y);
			a.pop();
			a.emplace(make_pair((x - (x / y) * y), x - (x / y) * y));
		}
		else
		{
			ans -= s * y;
			s = 0;
		}
	}
	out << ans;
	in.close();
	out.close();
}