#include <bits/stdc++.h>
using namespace std;

int main(){

    //freopen("castle.in", "r", stdin);
    //freopen("castle.out", "w", stdout);

    int n, s;
    cin >> n >> s;

    multiset< pair<int, int> > a;

    long long ans = 0;
    for(int i = 0; i < n; i++){
        int m, k;
        cin >> m >> k;
        a.insert({-min(k, m), m});
        ans += m;
    }

    for(auto it = a.begin(); it != a.end();){
        int k = -it->first,
            m = it->second;
        //cerr << k << " " << m << " " << s << endl;
        if(k == 0 || s == 0)
            break;
        auto tmp = it;
        if(k == m){
            ++it;
            a.erase(tmp);
            ans -= m;
            s--;
        }
        else if(1ll*s*k <= m){
            ans -= 1ll*s*k;
            break;
        }
        else{
            s -= m/k;
            ans -= m - m%k;
            int r = m%k;
            a.insert({-r, r});
            ++it;
            a.erase(tmp);
            /*
            ans -= k;
            m -= k;
            s--;
            a.insert({-min(k, m), m});
            */
        }
    }

    cout << ans << endl;

    return 0;
}
