#include <bits/stdc++.h>

using namespace std;

ifstream inp("castle.in");
ofstream outp("castle.out");

bool srt(pair<int, int> a, pair<int, int> b) {
    return a.second > b.second;
}

int main() {
    int n, s;
    inp >> n >> s;
    pair<int, int> ak[200000];
    int attackers = 0;
    int defenders = s;
    int pntr = 0;
    for(int i = 0; i < n; i++) {
        int a, k;
        inp >> a >> k;
        attackers += a;
        if(k > a) k = a;
        if(a % k != 0) {
            int a2, k2;
            a2 = a % k;
            k2 = a2;
            a -= a2;
            ak[pntr] = {a2, k2};
            pntr++;
        }
        ak[pntr] = {a, k};
        pntr++;
    }
    n = pntr;


        sort(ak, ak + n, srt);
        for(int i = 0; i < pntr && defenders > 0; i++) {
            int pos_defs = min(ak[i].first / ak[i].second, defenders);
            int remain = ak[i].first - ak[i].second * pos_defs;
            attackers -= (ak[i].first - remain);
            ak[i].first = remain;
            ak[i].second = min(remain, ak[i].second);
            defenders -= pos_defs;
        }

    outp << attackers;
    return 0;
}
