#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long lng;

struct pt
{
	lng a, k;
};
bool operator<(pt a, pt b)
{
	return a.a > b.a;
}
pt in[100000];

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	lng n, s; scanf("%lld%lld", &n, &s);
	for (int i = 0; i < n; ++i)
		scanf("%lld%lld", &in[i].k, &in[i].a);
	sort(in, in + n);
	for (int i = 0; i < n; ++i)
	{
		lng t = min(in[i].k / in[i].a, s);
		in[i].k -= t * in[i].a;
		s -= t;
		swap(in[i].a, in[i].k);
	}
	sort(in, in + n);
	lng ans = 0;
	for (int i = 0; i < n; ++i)
		ans += in[i].a;
	for (int i = 0; i < s; ++i)
		ans -= in[i].a;
	printf("%d", ans);
	return 0;
}