#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;
long long n, s, i, j=0, sum1=0, sum2=0;
pair <long, long> P[1000001];
pair <long, long> S[1000001];
int main() {
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	cin >> n >> s;
	for (i = 0; i < n; i++) {
		cin >> P[i].second>>P[i].first;
		sum1 += P[i].second;
		S[j].first = P[i].first;
		S[j].second = (P[i].second / P[i].first);
		j++;
		S[j].first = P[i].second%P[i].first;
		S[j].second = 1;
		j++;
	}
	sort(S, S+2*n);
	for (i = 2*n - 1; i >= 0; i--) {
		if (s>=S[i].second) {
			s -= S[i].second;
			sum2 += S[i].first*S[i].second;
		}
		else {
			sum2 += s*S[i].first;
			break;
		}
	}
	cout << sum1 - sum2;
}