#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

const long long maxn = (long long) 1e5 + 100;
const long long inf = (long long) 1e9 + 100;

long long n, s;
long long a[maxn];
long long k[maxn];

long long d[200][maxn];

pair <long long, long long> p[maxn];

long long go(long long pos, long long ost) {
	if (ost < 0) {
		return inf;
	}

	if (pos == n) {
		return d[pos][ost] = 0;
	} else if (d[pos][ost] == -1) {
		d[pos][ost] = inf;

		for (long long i = 0; i <= (long long)a[pos] / k[pos] + 1; i++) {
			if (i <= ost) {
				d[pos][ost] = min(d[pos][ost], go(pos + 1, ost - i) + max((long long)0, a[pos] - i * k[pos]));
			}
		}
	}

	return d[pos][ost];
}

bool comp(pair <long long, long long> a, pair <long long, long long> b) {
	return (long long) (b.first * a.second) < (long long) (a.first * b.second);
}

int main() {
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);

	scanf("%lld %lld", &n, &s);

	for (long long i = 0; i < n; i++) {
		scanf("%d %d", &a[i], &k[i]);
	}

	if (n <= 100) {
		for (long long i = 0; i < 200; i++) {
			for (long long j = 0; j < maxn; j++) {
				d[i][j] = -1;
			}
		}

		cout << go(0, s) << endl;
		return 0;
	}

	for (long long i = 0; i < n; i++) {
		p[i] = make_pair(a[i], k[i]);
	}

	sort(p, p + n, comp);

	for (long long i = 0; i < n; i++) {
		long long now;
		if (p[i].first % p[i].second == 0) {
			now = p[i].first / p[i].second;
		}
		else {
			now = p[i].first / p[i].second + 1;
		}

		if (s >= now) {
			s -= now;
			p[i].first -= now * p[i].second;
		} else {
			p[i].first -= s * p[i].second;
			s = 0;
		}
	}

	long long res = 0;

	for (long long i = 0; i < n; i++) {
		res += p[i].first;
	}

	cout << res << endl;

	return 0;
}
/*
3 3 4 2 1 1 10 8
*/