#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#define k first
#define a second 
using namespace std;


int main() {
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);

	int n, s;
	cin >> n >> s;
	vector <pair<int, int> > arr;
	for (int i = 0; i < n; i++) {
		int x, y;
		cin >> x >> y;
		arr.push_back(make_pair(y, x));
	}
	sort(arr.begin(), arr.end());
	reverse(arr.begin(), arr.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += arr[i].a;
	}
	for (int i = 0; i < n; i++) {
		if (s == 0) {
			cout << ans;
			return 0;
		}
		int x = arr[i].a / arr[i].k;
		x = min(x, s);
		s -= x;
		ans -= arr[i].k * x;
		arr[i] = make_pair(arr[i].a - arr[i].k * x, 0);
	}
	if (s == 0) {
		cout << ans;
		return 0;
	}
	sort(arr.begin(), arr.end());
	reverse(arr.begin(), arr.end());
	for (int i = 0; i < n; i++) {
		if (s != 0) {
			ans -= arr[i].a;
			s -= 1;
		}
	}
	cout << ans;

	fclose(stdin);
	fclose(stdout);
	return 0;
}