#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <ctime>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define int long long
#define sz(a) (int)(a.size())

int n, s;
const int MAXN = 1e5 + 100;
pair<int, int> a[MAXN];
int k[MAXN];
set<pair<int, int>> q;

signed main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	cin >> n >> s;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i].second >> a[i].first;
		q.insert({ min(a[i].first, a[i].second), i });
	}
	while (s > 0 && !q.empty())
	{
		pair<int, int> cur = *q.rbegin();
		q.erase(cur);
		int z = min(s, a[cur.second].second / cur.first);
		a[cur.second].second = a[cur.second].second - cur.first * z;
		s -= z;
		if (a[cur.second].second)
			q.insert({ min(a[cur.second].first, a[cur.second].second), cur.second });
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
		ans += a[i].second;
	cout << ans;
	return 0;
}