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

using namespace std;

multiset<pair<long long, long long> > s;

signed main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    long long n, d, res = 0;
    cin >> n >> d;
    for (long long i = 0; i < n; ++i) {
        long long t1, t2;
        cin >> t1 >> t2;
        s.insert(make_pair(t2, t1));
        res += t1;
    }
    while(s.size() > 0 && d > 0) {
        auto t = s.end();
        --t;
        auto p = (*t);
        s.erase(t);
        long long u = p.second / p.first;
        if (d >= u) {
            res -= p.first * u;
            d -= u;
            if (p.first * u < p.second) {
                s.insert(make_pair(p.second - p.first * u, p.second - p.first * u));
            }
        }
        else {
            res -= p.first * d;
            d = 0;
        }
    }
    cout << res << endl;
    return 0;
}
