#include <stdio.h>
#include <iostream>
#include <fstream>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <iterator>
#include <utility>
#include <queue>
#include <deque>
#include <stack>

using namespace std;

const int MAXN = 100000;
pair<int, int> a[MAXN + 1];
long long ans;

bool cmp(pair<int, int>& first, pair<int, int>& second) {
	return first.second > second.second;
}

int main() {
	ios_base::sync_with_stdio(false);
	ifstream cin("castle.in");
	ofstream cout("castle.out");

	int n, s;
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		cin >> a[i].second >> a[i].first;
	sort(a, a + n);
	reverse(a, a + n);
	for (int i = 0; i < n; i++) {
		ans += a[i].second;
		int temp = min(s, a[i].second / a[i].first);
		ans -= temp * a[i].first;
		s -= temp;
		a[i].second -= temp * a[i].first;
		if (i + 1 < n && s && a[i].second > min(a[i + 1].first, a[i + 1].second)) {
			ans -= a[i].second;
			a[i].second = 0;
			s--;
		}
	}
	sort(a, a + n, cmp);
	for (int i = 0; i < n && s; i++) {
		ans -= a[i].second;
		s--;
	}
	cout << ans << endl;
	return 0;
}