#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::string;
using std::array;
using std::pair;
using std::make_pair;

using std::min;
using std::max;
using std::abs;

template <typename T>
T input() {
    T res;
    cin >> res;
    return res;
}

#ifdef LOCAL
#define LASSERT(x) assert(x)
#else
#define LASSERT(x) {}
#endif

struct offer {
    uint32_t a;
    uint32_t t;
};

int main() {
    // save with C-x C-s
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifndef LOCAL
#define TASK "castle"
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
#endif

    uint32_t n, s;
    cin >> n >> s;

    vector<offer> offers;
    uint64_t sum = 0;
    for (uint32_t i = 0; i != n; ++i) {
        uint32_t a, k;
        cin >> a >> k;
        sum += a;

        if (a >= k)
            offers.emplace_back(offer {k, a / k});
        if (a % k != 0)
            offers.emplace_back(offer {a % k, 1});
    }

    std::sort(offers.begin(), offers.end(), [](const offer& f, const offer& s) {
        return f.a > s.a;
    });

    for (uint32_t i = 0; i != offers.size() and s != 0; ++i) {
        uint32_t howmuch = min(s, offers[i].t);
        s -= howmuch;
        sum -= howmuch * offers[i].a;
    }

    cout << sum << "\n";
    return 0;
}