#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <set>
#define ll long long
using namespace std;

const int MAXN = 1e5 + 111;

struct SS
{
	int a, k;
	SS() {}
	SS(int a, int k) : a(a), k(k) {}
};

int n, s;

SS a[MAXN];

multiset <SS> st;

bool operator <(SS a, SS b)
{
	return a.k < b.k || (a.k == b.k && a.a < b.a);
}

bool cmp(SS a, SS b)
{
	return a.a < b.a;
}

int main()
{
	freopen("castle.in", "r", stdin);
	freopen("castle.out", "w", stdout);
	scanf("%d %d", &n, &s);
	for (int i = 0; i < n; i++)
		scanf("%d %d", &a[i].a, &a[i].k);
	sort(a + 0, a + n);
	for (int i = n - 1; i >= 0; i--)
	{
		while (!st.empty())
		{
			SS bb = *st.rbegin();
			if (bb.k >= a[i].k && s > 0)
			{
				a[bb.a].a = 0;
				s--;
				st.erase(st.find(bb));
			}
			else
				break;	
		}
		if (a[i].a / a[i].k <= s)
		{
			s -= a[i].a / a[i].k;
			a[i].a %= a[i].k;
			st.insert(SS(i, a[i].a));
		}
		else
		{
			a[i].a -= (ll)s * a[i].k;
			s = 0;
		}
	}
	sort(a + 0, a + n, cmp);
	for (int i = n - 1; i >= 0; i--)
	{
		if (s > 0 && a[i].a > 0)
		{
			s--;
			a[i].a = 0;
		}
	}
	long long ans = 0;
	for (int i = 0; i < n; i++)
		ans += a[i].a;
	cout << ans;
	return 0;
}