#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>

using namespace std;

struct Region {
    int a, k;
    bool operator <(const Region &o) const {
        return k < o.k;
    }
};

int main() { 
#ifndef LOCAL
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
#endif // LOCAL
    int n, s;
    cin >> n >> s;
    long long a_sum = 0;
    priority_queue<Region> regions;
    for (int i = 0; i < n; i++) {
        Region r;
        cin >> r.a >> r.k;
        a_sum += r.a;
        regions.push(r);
    }

    while (s > 0 && !regions.empty()) {
        Region r = regions.top(); 
        regions.pop();
        int x = min(s, r.a / r.k);
        int killed = x * r.k;
        r.a -= killed;
        s -= x;
        a_sum -= killed;
        if (r.a < r.k) {
            r.k = r.a;
        }
        if (r.a != 0) {
            regions.push(r);
        }
    }

    cout << a_sum << endl;

    return 0;
}
