#include <algorithm>
#include <utility>
#include <fstream>
#include <vector>

using namespace std;

typedef long long ll;

ifstream cin("castle.in");
ofstream cout("castle.out");

vector<pair<ll, ll>> tower;

bool More(pair<ll, ll> a, pair<ll, ll> b) {
	return min(a.first, a.second) > min(b.first, b.second);
}

int main() {
	int n;
	ll s;
	cin >> n >> s;
	for (int i = 0; i < n; ++i) {
		ll a, k;
		cin >> a >> k;
		tower.push_back(make_pair(a / k * k, k));
		if (a % k)
			tower.push_back(make_pair(a % k, k));
	}
	sort(tower.begin(), tower.end(), More);
	ll res = 0;
	for (pair<ll, ll> q: tower) {
		ll a = q.first, k = q.second;
		// cout << a << ' ' << k << ' ' << s << '\n';
		if (s * k <= a) {
			res += a - s * k;
			s = 0;
		} else {
			s -= (a + k - 1) / k;
		}
	}
	cout << res << '\n';
}