#include <iostream>
#include <vector>
#include <set>
#include <cstdio>
#include <cassert>


using namespace std;

struct wall {
    int k, a, idx;

    wall() {}
    wall(int _k, int _a, int _idx) : k(_k), a(_a), idx(_idx) {}

    bool operator<(const wall &w) const {
        if (k != w.k) {
            return k < w.k;
        }
        return idx < w.idx;
    }
};

int main() {
#ifndef LOCAL
    assert(freopen("castle.in", "r", stdin));
    assert(freopen("castle.out", "w", stdout));
#endif // LOCAL
    int n, s;
    cin >> n >> s;
    set<wall> rm;
    int a, k;
    for (int i = 0; i < n; ++i) {
        cin >> a >> k;
        k = min(k, a);
        rm.insert(wall(k, a, i));
    }
    while (rm.size() > 0 && s > 0) {
        wall cur = *prev(rm.end());
        rm.erase(prev(rm.end()));
        int cc = min(cur.a / cur.k, s);
        s -= cc;
        cur.a -= cc * cur.k;
        if (cur.a > 0) {
            rm.insert(wall(min(cur.k, cur.a), cur.a, cur.idx));
        }
    }
    long long int ans = 0;
    for (wall p : rm) {
        ans += p.a;
    }
    cout << ans << endl;

    return 0;
}
