#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>

using namespace std;

#pragma warning (disable:4996)

#define ll long long int
#define mlp make_pair
#define x1 first
#define y1 second

ll n, a[100007], b[100007], s;
vector<pair<ll,ll> > v;

void sol() {
	int i, j;
	ll ans=0;
	cin >> n >> s;
	for (i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
		ans += a[i];
		if (a[i] / b[i] != 0)v.push_back(mlp(b[i], a[i] / b[i]));
		if (a[i] % b[i] != 0)v.push_back(mlp(a[i] % b[i], 1));
	}
	sort(v.rbegin(), v.rend());
	for (i = 0; i < v.size(); i++) {
		ans -= min(s, v[i].y1)*v[i].x1;
		s -= min(s, v[i].y1);
	}
	cout << ans;
}

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

	sol();
	return 0;
}