#include<iostream>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<iomanip>
#include<set>
#pragma warning(disable : 4996)

using namespace std;

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

	long long n, s;
	cin >> n >> s;

	vector<vector<long long> > h(n, vector<long long> (2));

	for (long long i = 0; i < n; i++) {
		cin >> h[i][1] >> h[i][0];
	}

	stable_sort(h.begin(), h.end());
	reverse(h.begin(), h.end());



		set<pair<long long, long long>> p;
		if (h[0][1] / h[0][0] >= s) {
			s = 0;
			h[0][1] = h[0][1] - s*h[0][0];
		}
		else {
			s = s - h[0][1] / h[0][0];
			h[0][1] = h[0][1] % h[0][0];
			pair<long long, long long> q;
			q.first = h[0][1];
			q.second = 0;
			p.insert(q);
		}
		long long i = 1;
		while(s > 0 && i < n) {
			if (p.size() != 0 && p.rbegin()->first > h[i][0]) {
				s = s - 1;
				h[p.rbegin()->second][1] = 0;
				p.erase(*p.rbegin());
			}
			else {
				if (h[i][1] / h[i][0] >= s) {
					h[i][1] = h[i][1] - s*h[i][0];
					s = 0;
				}
				else {
					s = s - h[i][1] / h[i][0];
					h[i][1] = h[i][1] % h[i][0];
					pair<long long, long long> q;
					q.first = h[i][1];
					q.second = i;
					p.insert(q);
					i++;
				}
			}
			if (s == 0)
				break;
		}
		long long o = 0;
		for (long long i = 0; i < n; i++) {
			o += h[i][1];
		}
		cout << o;


	/*if (y < s) {
		vector<long long> otv (n);
		for (long long i = 0; i < n; i++) {
			otv[i] = h[i][1] % h[i][0];
		}
		long long k = s - y;
		stable_sort(otv.begin(), otv.end());
		long long j = 0;
		if (s - y >= n) {
			cout << 0;
			return 0;
		}
		else {
			for (long long i = n - 1 - (s - y); i >= 0; i--) {
				j += otv[i];
			}
			cout << j;
			return 0;
		}
	}*/


	return 0;
}