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

using namespace std;

long long n, s, ans;
multiset < pair<long long, pair<long long, long long>> > st;

int main() {
	//ifstream cin("in.txt");
	//ofstream cout("out.txt");
	ifstream cin("castle.in");
	ofstream cout("castle.out");
	cin >> n >> s;
	for (int i = 1; i <= n; i++) {
		long long a, b;
		cin >> a >> b;
		st.insert({ b, {a, i} });
	}
	while (s != 0) {
		long long a, b, c;
		auto it = st.rbegin();
		c = it->second.second;
		if (it -> first == 0)
			break;
		if (it -> second.first / it -> first <= s) {
			s -= it->second.first / it->first;
			b = it->second.first - (it->second.first / it->first) * it->first;
			a = b;
			c = 
			st.erase(*it);
			st.insert({ a, {b,  c} });
		}
		else {
			b = it->second.first - s * it->first;
			a = b;
			st.erase(*it);
			st.insert({ a,{ b,  c } });
			s = 0;
		}
	}
	for (auto it = st.begin(); it != st.end(); it++)
		ans += it->second.first;
		cout << ans;
		return 0;
}