#include <bits/stdc++.h>

using namespace std;

void solve()
{
    int n, s;
    cin >> n >> s;

    vector<pair<int, int> > v;
    v.reserve(n);
    int64_t ans(0);

    for (int i = 0; i < n; ++i)
    {
        int a, k;
        cin >> a >> k;
        ans += a;
        v.push_back({k, a});
    }

    sort(v.rbegin(), v.rend());

    for (auto& it : v)
    {
        int need = it.second / it.first;
        if (s < need)
        {
            ans -= s * it.first;
            cout << ans << endl;
            return;
        }

        s -= need;
        ans -= need * it.first;
        it.second %= it.first;
        swap(it.first, it.second);

    }

    sort(v.rbegin(), v.rend());

    for (auto& it : v)
    {
        if (!s)
            break;
        --s;
        ans -= it.first;
    }

    cout << ans << endl;
    return;

}

#define FILE_NAME "castle"

int main()
{
#ifndef __DEBUG
    freopen(FILE_NAME ".in", "r", stdin);
    freopen(FILE_NAME ".out", "w", stdout);
#endif // __DEBUG
    ios_base::sync_with_stdio(false);
    cin.tie();

    solve();

    return 0;
}
