#include <stdio.h>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
using namespace std;

pair <long long, long long> p[100005];
vector <long long> v;

int main()
{
	ios::sync_with_stdio(false);
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	long long n, S;
	cin >> n >> S;
	long long sum = 0;

	for (long long i = 0; i < n; i++)
	{
		cin >> p[i].second >> p[i].first;
	}
	sort(p, p + n);

	long long i = n - 1;
	for (; i >= 0; i--)
	{
		if (S == 0)
		{
			v.push_back(p[i].first);
			sum += p[i].second;
			continue;
		}
		if (p[i].second / p[i].first <= S)
		{
			S -= p[i].second / p[i].first;
			v.push_back(p[i].second % p[i].first);
			sum += p[i].second % p[i].first;
		}
		else
		{
			//v.push_back(p[i].second - S * p[i].first);
			sum += p[i].second - S * p[i].first;
			S = 0;	
		}  
	}
	if (S == 0)
	{
		cout << sum << endl;
		return 0;
	}                     
	sort(v.begin(), v.end());
	long long j = v.size() - 1;
	while (S > 0 && j >= 0)
	{
		sum -= v[j];
		j--;
		S--;
	}
	cout << sum << endl;
     
	return 0;
}