#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <cmath>

#pragma comment(linker, "/STACK:256000000")

using namespace std;

typedef long long int ll;
typedef long double ld;

const int MAX_N = 1000 * 100 + 5;

struct point
{
	ll at;
	ll can;
};

bool operator< (const point &a, const point &b)
{
	return min(a.at, a.can) < min(b.at, b.can);
}

int n;
ll s;
point arr[MAX_N];
multiset<point> gg;

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);

	scanf("%d %lld", &n, &s);

	ll answer = 0;

	for (int i = 0; i < n; ++i)
	{
		scanf("%lld %lld", &arr[i].at, &arr[i].can);
		answer += arr[i].at;
		gg.insert(arr[i]);
	}

	int max_at;
	ll at_max;
	point now;
	ll pos;
	while (s > 0 && !gg.empty())
	{
		now = *(--gg.end());
		gg.erase((--gg.end()));

		if (now.at >= now.can)
		{
			pos = now.at / now.can;
			if (pos <= s)
			{
				answer -= now.can*pos;
				now.at %= now.can;
				gg.insert(now);
				s -= pos;
			}
			else
			{
				answer -= now.can*s;
				break;
			}
		}
		else
		{
			answer -= now.at;
			--s;
		}
	}

	printf("%lld", answer);

	fclose(stdin);
	fclose(stdout);

	return 0;
}