#include <iostream>
#include <cstdlib>
#include <algorithm>

using namespace std;

typedef long long int ll;

const int SIZE = 200000;

int a[SIZE], k[SIZE];

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];
	}

	while (s > 0 && sum > 0) {
		int max = 0;

		for (int i = 0; i < n; i++)
			if (min(a[i], k[i]) > min(a[max], k[max]))
				max = i;

		int t = min(a[max] / k[max], s);
		if (t == 0) {
			sum -= a[max];
			a[max] = 0;
			s--;
		}
		else {
			a[max] -= k[max] * t;
			s -= t;
			sum -= k[max] * t;
		}

	}

	cout << sum << endl;
}