#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <set>

using namespace std;

ifstream in("castle.in");
ofstream out("castle.out");

typedef long long ll;

struct seg {
    ll a, k;

    seg(ll a, ll k) : a(a), k(k) {}

    bool operator<(seg b) const {
        ll as = k;
        if (a / k == 0)
            as = a;

        ll bs = b.k;
        if (b.a / b.k == 0)
            bs = b.a;

        return as > bs;
    }
};

int main() {
    ll n, s;
    in >> n >> s;

    ll ans = 0;
    multiset<seg> arr;

    ll a, k;
    for (int i = 0; i < n; ++i) {
        in >> a >> k;

        ans += a;
        arr.insert(seg(a, k));
    }

    while (s > 0 && arr.size() > 0) {
        seg x = *arr.begin();
        arr.erase(arr.begin());

        if (x.a / x.k == 0) {
            ans -= x.a;
            s-=1;
        } else {
            ans -= min(s, x.a / x.k) * x.k;
            s -= min(s, x.a / x.k);
            x.a %= x.k;
            if (x.a != 0) {
                arr.insert(x);
            }
        }
    }


    out << ans;
    return 0;
}
