#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<set>

using namespace std;
bool sortf(pair<int, int> a, pair<int, int> b) {
    return min(a.first, a.second) < min(b.first, b.second);
}
int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    long long n, s;
    cin >> n >> s;
    pair<long long, long long> a[n];
    for (long long i = 0; i < n; i++) {
        cin >> a[i].second >> a[i].first;
        a[i].first *= -1;
    }
    sort(a, a + n);
    set<pair<long long, long long> > help;
    for (long long i = 0; i < n; i++) {
        a[i].first *= -1;
        //cout << -(help.begin() -> second) << endl;
        while (help.size() > 0 && -(help.begin() -> second) > a[i].first && s > 0) {
            help.erase(help.begin());
            s--;
            //cout << "X";
        }
        if (s >= a[i].second / a[i].first) {
            s -= a[i].second / a[i].first;
            a[i].second %= a[i].first;
        } else {
            a[i].second -= a[i].first * s;
            s = 0;
        }
        //cout << a[i].second << ' ' << a[i].first << ' ' << s << endl;
        a[i].first = 0;
        a[i].second *= -1;
        help.insert(a[i]);
        //cout << a[i].second << ' ' << a[i].first << ' ' << s << endl;
    }
    long long ans = 0;
    for (auto elem : help) {
        //cout << elem.second << ' ';
        if (s > 0) {
            s--;
        } else {
            ans += -elem.second;
        }
    }
    cout << ans;
}
