#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <iomanip>
using namespace std;

#ifdef _DEBUG
#include <fstream>
ifstream cin("input.txt");
ofstream cout("output.txt");
#else
#include <fstream>
ifstream cin("castle.in");
ofstream cout("castle.out");
#endif

int x , s;

vector < pair < int, int > > a;


int main() {
	cin >> x >> s;
	for (int i = 0; i < x; i++) {
		int l, r;
		cin >> l >> r;
		a.push_back({ r , int(l / r) * r });
		a.push_back({ r , l % r });
	}
	sort(a.begin(), a.end());
	int f = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i].second % a[i].first == 0)
			f += a[i].second / a[i].first;
		else
			f += a[i].second / a[i].first + 1;
	}
	if (f <= s) {
		cout << 0;
	}
	else {
		int ans = 0;
		f -= s;
		for (int i = 0; i < a.size(); i++) {
			if (f > 0) {
				int add = 0;
				if (a[i].second % a[i].first == 0)
					add = a[i].second / a[i].first;
				else
					add = a[i].second / a[i].first + 1;
				if (f >= add) {
					f -= add;
					ans += add * a[i].first;
				}
				else {
					ans += f * a[i].first;
					f = 0;
				}
			}
		}
		cout << ans;
	}
}