#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const long long MAXN = 1e5 + 13;

long long n, s;

vector<pair<int, int>> wall;

int main() {
	//freopen("tests.txt", "r", stdin);
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	
	cin >> n >> s;
	long long need = 0;

	for (long long i = 1; i <= n; i++) {
		long long a, k;
		cin >> a >> k;
		need += a;
		long long t = a % k;
		a = a - t;
		wall.push_back(make_pair(k, a));
		if (t != 0) {
			wall.push_back(make_pair(t, t));
		}
	}
	sort(wall.begin(), wall.end());

	long long kol = 0;
	for (long long i = wall.size() - 1; i >= 0; i--) {
		if (!s)
			break;
		long long a = wall[i].second, k = wall[i].first;
		if (a / k <= s) {
			kol += a;
			s -= a / k;
		} else{
			kol += s * k;
			s = 0;
		}
	}

	cout << need - kol;
	return 0;
}