#include <bits/stdc++.h>
#define fr(i, n) for (ll i = 0; i < n; i++)
#define frab(i, a, b) for (ll i = a; i < b; i++)
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;

const ll N = 1e5 + 1;

struct tn {
    ll a, k;
    bool operator < (const tn x) const {
        return min(a, k) > min(x.a, x.k);
    }
} ar[N];

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    ll n, s;
    cin >> n >> s;
    multiset <tn> st;
    fr(i, n) {
        cin >> ar[i].a >> ar[i].k;
        st.insert(ar[i]);
    }
    while (s && st.size()) {
        tn tmp = *st.begin();
        st.erase(st.begin());
        ll val = min(s, tmp.a / tmp.k);
        if (val == 0)
            val++;
        s -= val;
        tmp.a -= val * tmp.k;
        if (tmp.a > 0)
            st.insert(tmp);
    }
    ll ans = 0;
    for (multiset <tn> :: iterator it = st.begin(); it != st.end(); it++)
        ans += (*it).a;
    cout << ans;

}
