#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>

using namespace std;

#define vec vector
#define ALL(x) (x).begin(), (x).end()
#define mp make_pair

typedef long long ll;
typedef pair< int, int > pii;

bool solve() {
	
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);

	int n, s;
	scanf("%d %d", &n, &s);

	vec< int > a(n + 1), k(n + 1);

	ll res = 0;

	for (int i = 1; i <= n; i++) {
		scanf("%d %d", &a[i], &k[i]);
		res += a[i];
	}

	for (int iter = 0; iter < 2; iter++) {
		vec< pii > perm;

		for (int i = 1; i <= n; i++) {
			int d = min(a[i], k[i]);
			perm.push_back(mp(d, i));
		}

		sort(ALL(perm));
		reverse(ALL(perm));

		for (int it = 0; it < n; it++) {
			int d, id;
			tie(d, id) = perm[it];
			if (d == 0) break;
			// k * d <= a[i]
			int K = a[id] / d;
			K = min(K, s);
			res -= K * d;
			a[id] -= K * d;
			s -= K;
		}
	}

	cout << res << '\n';

	return true;
}

int main() {
	
	//while (solve());
	solve();

	return 0;
}