#include <bits/stdc++.h>
using namespace std;

#define NAME "castle"
#define long long long

int main() {
#ifndef NO_FILES
	freopen(NAME".in", "r", stdin);
	freopen(NAME".out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n; cin >> n;
	int s; cin >> s;
	vector<pair<int, int>> wall(n);
	for (int i = 0; i < n; ++i) {
		cin >> wall[i].second >> wall[i].first;
		wall[i].first = min(wall[i].first, wall[i].second);
	}
	sort(wall.rbegin(), wall.rend());
	// k = first; a = second
	for (auto &w: wall) {
		long x = min(w.second / w.first, s);
		w.second -= x * w.first;
		w.first = min(w.first, w.second);
		s -= x;
	}
	sort(wall.rbegin(), wall.rend());
	for (auto &w: wall) {
		if (w.first == 0) break;
		long x = min(w.second / w.first, s);
		w.second -= x * w.first;
		w.first = min(w.first, w.second);
		s -= x;
	}

	long ans = 0;
	for (auto w: wall)
		ans += w.second;

	cout << ans << endl;
}

