#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>

using namespace std;

typedef long long ll;

struct Wall {
    ll en, pow;
    int id;
    Wall(ll _en, ll _pow, int _id) { en = _en, pow = _pow, id = _id; }
};

bool operator<(Wall x, Wall y) {
    if (x.pow == y.pow) return x.id < y.id;
    return x.pow > y.pow;
}

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);

    int n;
    ll s;
    cin >> n >> s;
    set<Wall> all;
    for (int i = 0; i < n; ++i) {
        ll a, k;
        cin >> a >> k;
        k = min(k, a);
        all.insert(Wall(a, k, i));
    }
    while (s > 0 && !all.empty()) {
        Wall cur = *all.begin();
        ll nd = cur.en / cur.pow;
        ll add = min(nd, s);
        s -= add;
        Wall ncur = Wall(cur.en, cur.pow, cur.id);
        all.erase(cur);
        ncur.en -= ncur.pow * add;
        ncur.pow = min(ncur.pow, ncur.en);
        if (ncur.en > 0) all.insert(ncur);
    }
    ll ans = 0;
    for (auto it = all.begin(); it != all.end(); ++it) {
        ll dd = (*it).en;
        ans += dd;
    }
    cout << ans;
    return 0;
}