#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

#define pii pair <long long, int>

const int N = 1e5;
long long a[N];
long long k[N];

struct cmp
{
	bool operator()(pii a, pii b)
	{
		if (a.first != b.first)
			return a.first > b.first;
		return a.second < b.second;
	}
};

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	int n, s;
	cin >> n >> s;
	for (int i = 0; i < n; ++i)
		cin >> a[i] >> k[i];
	set <pair <long long, int> , cmp> q;
	for (int i = 0; i < n; ++i)
		q.insert({ min(k[i], a[i]), i });
	//long long answer = 0;
	while (s > 0 && !q.empty())
	{
		pii front = *q.begin();
		q.erase(q.begin());
		int id = front.second;
		long long amount = a[id] / front.first;
		int moved = min(s, (int)amount);
		//answer += moved * front.first;
		a[id] -= moved * front.first;
		if (a[id] != 0)
			q.insert({ min(k[id], a[id]), id });
		s -= moved;
	}
	long long cur = 0;
	for (int i = 0; i < n; ++i)
		cur += a[i];
	cout << cur;
	return 0;
}