#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct mde
{
	long long x, y;
};

bool lessp(mde a, mde b)
{
	return a.x > b.x;
}



int main()
{
	long long n, s, ans = 0;
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	cin >> n >> s;
	vector<mde> mas;
	vector<long long> x;
	x.assign(n, 0);
	for (int i = 0; i < n; i++)
	{
		long long x, y;
		cin >> x >> y;
		mde k, l;
		k.x = y;
		k.y = x / y;
		l.x = x % y;
		l.y = 1;
		mas.push_back(k);
		mas.push_back(l);
		ans += x;
	}
	sort(mas.begin(), mas.end(), lessp);
	for (int i = 0; i < mas.size(); i++)
	{
		if (mas[i].y < s)
		{
			s -= mas[i].y;
			ans -= mas[i].x * mas[i].y;
		}
		else
		{
			ans -= mas[i].x * s;
			s = 0;
		}
	}
	cout << ans;
	return 0;
}