#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
const long long N = (long long)1e5 + 113;

struct el {
	long long a, k;
	el(long long a = 0, long long k = 0) : a(a), k(k) {}
};
bool operator <(el a, el b) {
	return a.k > b.k || (a.k == b.k && a.a > b.a);
}

long long n, s, a, k, def, all;
vector <el> vec;
set <long long> st;
int main() {
	//freopen("input.txt", "r", stdin);
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	cin >> n >> s;

	for (long long i = 1; i <= n; i++) {
		cin >> a >> k;
		all += a;
		vec.push_back(el(a, k));
	}
	sort(vec.begin(), vec.end());

	for (long long i = 0; i < n; i++) {
		if (s == 0)
			break;

		a = vec[i].a;
		k = vec[i].k;

		while (s && !st.empty() && (-(*st.begin())) >= k) {
			def -= *st.begin();
			st.erase(st.begin());
			s--;
		}

		long long needDel = min(s, a / k);
		
		def += needDel * k;
		a -= needDel * k;
		s -= needDel;
		if(a)
			st.insert(-a);
	}

	while (s && !st.empty()) {
		def -= *st.begin();
		s--;
	}

	cout << all - def;
}