#include <bits/stdc++.h>

using namespace std;

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

    priority_queue<pair<int, int> > pr;
    int64_t ans(0);

    for (int i = 0; i < n; ++i)
    {
        int a, k;
        cin >> a >> k;
        if (a)
            ans += a,
            pr.push({min(k, a), a});
    }

    while (pr.size())
    {
        auto it = pr.top(); pr.pop();
        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;

        it.first = it.second;
        if (it.first)
            pr.push(it);
    }

    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;
}
/**
10 1
200 1
200 2
200 3
200 4
200 5
200 6
200 7
200 8
200 9
200 500
*/
