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

#pragma warning (disable:4996)

#define ll long long int
#define mp make_pair

using namespace std;

ll n,s;
pair<ll, ll> p[100005];

void solve() {
	ll i, j,a,q,sum=0,k,aa,kk,l,r,ss;
	for (i = 0; i < n; i++) {
		scanf("%I64d%I64d", &a, &k);
		p[i] = mp(k, a);
		sum += a;
	}
	sort(p, p + n);
	for (i = n-1; i >0&&s>0; i--) {
		k = p[i].first;
		a = p[i].second;
		kk = p[i - 1].first;
		aa = p[i - 1].second;
		if (s <= a / k) {
			sum -= s*k;
			s = 0;
		}
		else {
			s -= a / k;
			sum -= a / k*k;
			a %= k;
			ss = s - 1;
			if (a + min(ss, aa / kk)*kk > min(s, aa / kk)*kk) {
				s--;
				sum -= a;
			}
		}
	}
	i = 0;
	k = p[i].first;
	a = p[i].second;
	q = min(s, a / k);
	sum -= q*k;
	a %= k;
	s -= q;
	if (s > 0 && a > 0) {
		sum -= a;
		s--;
	}
	printf("%I64d", sum);
	return;
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	freopen("castle.in", "rt", stdin);
	freopen("castle.out", "wt", stdout);
#endif
	scanf("%I64d%I64d", &n,&s);
	solve();
	return 0;
}
