#include <fstream>
#include <algorithm>
#include <set>
#include <iostream>

using namespace std;

int main(){
    const long long FLAG = 100000000000;
    ifstream fin("castle.in");
    ofstream fout("castle.out");
    long long n, s, summ = 0;

    fin >> n >> s;

    multiset< pair<long long, long long> > cheat;
    pair<long long, long long> cur;
    long long cur_i;

    for(long long i = 0; i < n; ++i){
        fin >> cur.second >> cur.first;
        cur.first = -cur.first;
        cheat.insert(cur);
        summ += cur.second;
    }

    while (cheat.size() > 0 && s > 0){
        cur = *(cheat.begin());
        cheat.erase(cheat.begin());
        if (cur.second == FLAG){
            s -= 1;
            summ += cur.first;
        }
        else{
            cur_i = min(cur.second / (-cur.first), s);
            s -= cur_i;
            cur.second -= cur_i * (-cur.first);
            summ -= cur_i * (-cur.first);
            if (cur.second > 0){
                cheat.insert(make_pair(-cur.second, FLAG));
            }
        }
    }

    fout << summ << endl;

    fin.close();
    fout.close();
    return 0;
}
