#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];


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);
	reverse(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i)
	{
		int z = a[i].second / a[i].first;
		if (s >= z)
			a[i].second -= z * a[i].first, s -= z;
		else
			a[i].second -= s * a[i].first, s = 0;
		if (i != n && a[i + 1].first <= a[i].second && s > 0)
			a[i].second = 0, s -= 1;
	}
	int ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans += a[i].second;
	}
	cout << ans;
	return 0;
}
