#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <ciso646>
#include <cmath>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <initializer_list>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef long double ld;

time_t _timer;
void _pre()
{
	_timer = clock();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#ifdef ANDREIKKAA
	assert(freopen("input.txt", "r", stdin) != nullptr);
#else
	assert(freopen("castle.in", "r", stdin) != nullptr);
	assert(freopen("castle.out", "w", stdout) != nullptr);
#endif
}

void _post()
{
#ifdef ANDREIKKAA
	cout << "\n\n\nTime: " << (clock() - _timer) / (ld)CLOCKS_PER_SEC << endl;
	while (228);
#endif
}

void _solve()
{
	int n, s;
	cin >> n >> s;

	ll sum = 0;
	map<ll, ll> m;
	for (int i = 0; i < n; ++i)
	{
		int a, k;
		cin >> a >> k;
		sum += a;
		m[k] += a / k;
		++m[a % k];
	}

	ll cnt = 0;
	for (auto it = m.rbegin(); it != m.rend() and s > 0; ++it)
	{
		if (s >= it->second)
		{
			s -= it->second;
			cnt += it->second * it->first;
		}
		else
		{
			cnt += s * it->first;
			s = 0;
		}
	}
	cout << sum - cnt << endl;
}

int main()
{
	_pre();
	_solve();
	_post();
}