#include<fstream>
#include<algorithm>

using namespace std;

fstream cin("castle.in");
fstream cout("castle.out");

int main(){
    long long n, s1;
    cin >> n >> s1;
    long long all = 0;
    pair<long long, long long> s[2 * n];
    for (long long i = 0; i < n; ++i){
        long long a, b;
        cin >> a >> b;
        s[2 * i] = {b, (a - a % b) / b};
        s[2 * i + 1] = {a % b, 1};
        all += a;
    }
    sort(s, s + 2 * n);
    long long cur = 0;
    for (long long i = 2 * n - 1; i >= 0; --i){
        if (cur + s[i].second <= s1){
            all -= s[i].second * s[i].first;
            cur += s[i].second;
        }
        else{
            all -= (s1 - cur) * s[i].first;
            break;
        }
    }
    cout << all;
}
