#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;
    vector<pair<int, int>> v;
    multiset<pair<int, int>> st;
    long long num = 0;

    for (int i = 0; i < n; ++i) {
        int a, k;
        cin >> a >> k;
        v.push_back({a, k});
        st.insert({k, a});
        num += a;
    }
    while (not st.empty() and (s > 0)) {
        pair<int, int> p = *st.rbegin();
     //   p.first *= -1;
        st.erase(p);
        int a = p.second, k = p.first;
        if (s >= a / k) {
            num -= a - (a % k);
            s -= a / k;

            a %= k;
            k = a;
            if (a != 0) {
                st.insert({k, a});
            }
        } else {
            num -= s * k;
            cout << num << endl;
            return 0;
        }
    }

    cout << num << endl;
    return 0;

}
