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

using namespace std;

#pragma warning(disable:4996)

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long ll;

ll a[100100], k[100100];

multimap<ll, int> m;

void solve() {
	int n;
	ll s, ans = 0;
	scanf("%d%lld", &n, &s);
	for (int i = 0; i < n; ++i) {
		scanf("%lld%lld", &a[i], &k[i]);
		ans += a[i];
		m.insert(make_pair(min(a[i], k[i]), i));
	}
	while (s > 0 && !m.empty()) {
		auto it = prev(m.end());
		auto p = *it;
		ans -= min(s, a[p.y] / p.x) * p.x;
		s -= min(s, a[p.y] / p.x);
		a[p.y] %= p.x;
		m.erase(it);
		if (a[p.y] != 0) {
			m.insert(mp(a[p.y], p.y));
		}
	}
	printf("%lld", ans);
}

int main() {
#pragma comment(linker,"/STACK:536870912")
#ifdef _DEBUG
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#else
	freopen("castle.in", "rt", stdin);
	freopen("castle.out", "wt", stdout);
#endif
	solve();
	return 0;
}