#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <ctime>
#include <set>
#include <map>
#include <iomanip>
#include <cstdio>
#include <cstdlib>

using namespace std;

#define int long long
#define sz(a) (int)(a.size())

int n, s;
const int MAXN = 1e5 + 100;
pair<int, int> a[MAXN];
int k[MAXN];

bool cmp(pair<int, int> a, pair<int, int> b)
{
	return max(a.first, a.second) > max(b.first, b.second) || 
		(max(a.first, a.second) == max(b.first, b.second) && a.second > b.second);
}

signed main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	cin >> n >> s;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i].second >> a[i].first;
	}
	sort(a + 1, a + n + 1, cmp);
	int any = 1;
	while (s > 0 && any)
	{
		any = 0;
		sort(a + 1, a + n + 1, cmp);
		for (int i = 1; i <= n; ++i)
		{
			if (a[i].second == 0)
				continue;
			int z = a[i].second / a[i].first;
			if (z <= s)
			{
				s -= z;
				a[i].second -= a[i].first * z;
				any = 1;
			}
			else
			{
				a[i].second -= a[i].first * s;
				s -= s;
				any = 1;
			}
			if (i != n && s > 0 && max(a[i].first, a[i].second) >= max(a[i + 1].first, a[i + 1].second))
			{
				s -= 1;
				a[i].second = 0;
				any = 1;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans += a[i].second;
	}
	cout << ans;
	return 0;
}
