#include <bits/stdc++.h>

using namespace std;

bool cmp(pair <long long, long long> &p1, pair <long long, long long> &p2) {
    return p1 > p2;
}

int main() {
    long long n, s, z = 0;
    scanf("%lld%lld", &n, &s);
    vector < pair<long long, long long> > mas;
    mas.reserve(2*n);
    long long k, a;
    for(int i = 0; i < n; i++) {
        scanf("%lld%lld", &a, &k);
        z += a;
        if(a < k) {
            mas.push_back(make_pair(a, 1));
        } else if(a%k == 0) {
            mas.push_back(make_pair(k, a/k));
        } else {
            mas.push_back(make_pair(k, a/k));
            mas.push_back(make_pair(a%k, 1));
        }
    }
    long long ans = 0;
    sort(mas.begin(), mas.end(), &cmp);
    for(int i = 0; i < mas.size(); i++) {
        if(s == 0) break;
        if(mas[i].second <= s) {
            s -= mas[i].second;
            ans += mas[i].first*mas[i].second;
        } else {
            ans += mas[i].first*s;
            s = 0;
            break;
        }
    }
    printf("%lld", z-ans);
    return 0;
}
