#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;

map < int, ll > mp;

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	int n, s;
	scanf("%d %d", &n, &s);
	int a, k;
	ll sum = 0;
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d", &a, &k);
		sum += a;
		mp[k] += a / k;
		if (a % k != 0)
			mp[a % k]++;
	}
	ll kk, val, cnt, d;
	for (auto it = mp.rbegin(); it != mp.rend(); it++)
	{
		val = it->first;
		kk = it->second;
		cnt = min(kk, (ll)s);
		d = cnt * val;
		s -= cnt;
		sum -= d;
	}
	printf("%d", sum);
	return 0;
}