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

using namespace std;

vector<int> ai, ki;

struct cmp
{
	bool operator()(int i, int j)
	{
		if (ki[i] != ki[j])
			return ki[i] > ki[j];
		return i < j;
	}
};

int main()
{
	ifstream cin("castle.in");
	ofstream cout("castle.out");
	int n;
	long long s;
	cin >> n >> s;
	ai.resize(n), ki.resize(n);
	for (int i = 0; i < n; ++i)
		cin >> ai[i] >> ki[i], ki[i] = min(ai[i], ki[i]);
	set<int, cmp> st;
	for (int i = 0; i < n; ++i)
		st.insert(i);
	while (s > 0)
	{
		auto it = st.begin();
		int x = *it;
		st.erase(it);
		if (ki[x] == 0)
			break;
		int xi = min(s, 1LL * ai[x] / ki[x]);
		s -= xi;
		ai[x] -= xi * ki[x];
		ki[x] = min(ki[x], ai[x]);
		st.insert(x);
	}
	cout << accumulate(ai.begin(), ai.end(), 0LL) << endl;
}