#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){
    ifstream in("castle.in");
    ofstream out("castle.out");
    long long n, s;
    in >> n >> s;
    vector<vector<long long> > v(n, vector <long long> (2));
    for(long long i = 0; i < n; i++){
        in >> v[i][1] >> v[i][0];
    }
    sort(v.rbegin(), v.rend());
    long long j;
    cout << "hugvfhv";
    while(s > 0 and v[0][0] > 0){
        j = min(v[0][1] / v[0][0], s);
        s -= j;
        v[0][1] -= v[0][0] * j;
        v[0][0] = min(v[0][0], v[0][1]);
        sort(v.rbegin(), v.rend());
    }
    long long res = 0;
    for(long long i = 0; i < n; i++){
        res += v[i][1];
    }
    out << res << endl;
    return 0;
}
