//#include "stdafx.h"
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>

using namespace std;
long long a, b, c, i, n, k, z, j;
pair<long long, long long> m[200000];
struct cmp
{
	bool operator()(const pair<long long, long long> & a, const pair<long long, long long> & b)
	{
		return (a.first < b.first);
	}
};
multiset<pair<long long, long long>,cmp > m1;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	scanf("%I64d%I64d", &n, &k);
	for (int i = 1; i <= n; i++)
	{
		scanf("%I64d%I64d", &a, &b);
		m[i] = make_pair(a, b);
		if (b <= a)
			m1.insert(make_pair(b, i));
		else
			m1.insert(make_pair(a, i));
	}
	while (1 == 1)
	{
		if (k <= 0 || m1.empty())
			break;
		pair<long long, long long> ee;
		auto it = m1.end();
		it--;
		ee = *it;
		m1.erase(it);
		if (m[ee.second].first / ee.first >= k)
		{
			m[ee.second].first -= k*ee.first;
			k = 0;
		}
		else
		{
			k -= m[ee.second].first / ee.first;
			m[ee.second].first %= ee.first;
			if (m[ee.second].first > 0)
				m1.insert(make_pair(m[ee.second].first, ee.second));
		}
	}
	long long res = 0;
	for (int i = 1; i <= n; i++)
		res += m[i].first;
	printf("%I64d", res);
	return 0;
}