#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, a, b;
    in >> n >> s;
    vector<vector<long long> > v(2 * n, vector <long long> (2));
    for(long long i = 0; i < n; i++){
        in >> a >> b;
        v[2 * i][1] = a - a % b;
        v[2 * i][0] = b;
        v[2 * i + 1][0] = a % b;
        v[2 * i + 1][1] = a % b;
    }
    sort(v.rbegin(), v.rend());
    long long j;
    for(long long i = 0; i < 2 * n; i++){
        if(v[i][0] > 0){
        j = min(v[i][1] / v[i][0], s);
        s -= j;
        v[i][1] -= j * v[i][0];
        }
    }
    long long res = 0;
    for(long long i = 0; i < 2 * n; i++){
        res += v[i][1];
    }
    out << res << endl;
    return 0;
}
