#include <iostream>
#include <cstdlib>
#include <queue>
#include <functional>
#include <algorithm>

using namespace std;

typedef long long int ll;

const int SIZE = 200000;

struct cmp
{
	bool operator() (pair<int, int> a, pair<int, int> b) { return a > b; }
};

int a[SIZE], k[SIZE];
priority_queue<pair<int, int>, vector<pair<int, int>>, less<pair<int, int>>> maxim;

int main()
{
#ifndef _CONSOLE
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
#else
	freopen("input.txt", "r", stdin);
#endif

	int n, s;
	ll sum = 0;

	cin >> n >> s;

	for (int i = 0; i < n; i++) {
		cin >> a[i] >> k[i];
		sum += a[i];
		maxim.push(make_pair(min(a[i], k[i]), i));
	}

	while (s > 0 && sum > 0) {
		pair<int, int> max = maxim.top();
		maxim.pop();

		int t = min(s, a[max.second] / k[max.second]);

		if (t == 0) {
			sum -= a[max.second];
			a[max.second] = 0;
			s--;
		}
		else {
			a[max.second] -= k[max.second] * t;
			s -= t;
			sum -= k[max.second] * t;
		}

		maxim.push(make_pair(min(a[max.second], k[max.second]), max.second));
	}

	cout << sum << endl;
}