#include <stdio.h>
#include <stdlib.h>

using namespace std;

struct t{
	__int64 z, q;
};

t w[100001];
int n, f = 0;
__int64 a, k, ans, s, max = 0, ind;

int compare(const void * a, const void * b)
{
	t x = *(t*)a;
	t y = *(t*)b;
	return y.q - x.q;
}


int comparez(const void * a, const void * b)
{
	t x = *(t*)a;
	t y = *(t*)b;
	return y.z - x.z;
}

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	scanf("%d%I64d", &n, &s);
	for (int i = 0; i < n; i++)
	{
		scanf("%I64d%I64d", &a, &k);
		w[i].z = a;
		w[i].q = k;
	}
	while (s > 0 && !f)
	{
		qsort(w, n, sizeof(__int64) * 2, compare);
		max = 0;
		for (int i = 0; i < n; i++)
		{
			if (w[i].q < max && w[i].z)
			{
				break;
			}
			s -= w[i].z / w[i].q;
			w[i].z %= w[i].q;
			if (s < 0)
			{
				w[i].z += (-s) * w[i].q;
				break;
			}
			if (w[i].z > max)
				max = w[i].z;
		}
		f = 1;
		if (s > 0)
		{
			for (int i = 0; i < n; i++)
			{
				if (w[i].z)
					f = 0;
				if (w[i].z > w[i].q || w[i].z < max)
					continue;
				if (!w[i].z)
					break;
				s--;
				w[i].z = 0;
				if (!s)
					break;
			}
		}
	}
	for (int i = 0; i < n; i++)
		ans += w[i].z;
	printf("%I64d", ans);
	return 0;
}