#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int maxn = 100005;
int n;
ll s, suma = 0;

struct elem {
    ll a, k, i;
    elem(ll _a, ll _k, ll _i): a(_a), k(_k), i(_i) {}
    friend bool operator < (elem a, elem b) {
        if (a.k != b.k)
            return a.k > b.k;
        if (a.a != b.a)
            return a.a < b.a;
        if (a.i != b.i)
            return a.i < b.i;
    }
};

set<elem> st;

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "wt", stdout);
    cin >> n >> s;
    for (int i = 0; i < n; ++i) {
        ll a, k;
        cin >> a >> k;
        suma += a;
        st.insert(elem(a, k, i));
    }

    while (s > 0 && !st.empty()) {
            ll a = st.begin() -> a;
            ll k = st.begin() -> k;
            ll i = st.begin() -> i;
            st.erase(*st.begin());
            int d = min(s, a / k);
            //cout << "a, k, i, d: " << a << ' ' << k << ' ' << i << ' ' << d << endl;
            s -= d;
            suma -= d * k;
            a -= d * k;
            if (a != 0 && s != 0)
                st.insert(elem(a, a, i));
        }

    cout << suma;


    return 0;
}

/*
3 3
4 2
1 1
10 8
*/
