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

using namespace std;

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

struct seg {
    int a, k;

    seg(int a, int k) : a(a), k(k) {}
};

bool cmp(seg a, seg b) {
    return a.k > b.k;
}

bool cmp1(seg a, seg b) {
    return a.a > b.a;
}

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

    long long ans = 0;
    vector<seg> arr;

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

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


    sort(arr.begin(), arr.end(), cmp);


    for (int i = 0; i < n; ++i) {
        int now = arr[i].a / arr[i].k;

        if (now <= s) {
            s -= now;
            ans -=  now * arr[i].k;

            arr[i].a %= arr[i].k;
        } else {
            ans -= s * arr[i].k;

            out << ans << endl;
            return 0;
        }
    }

    sort(arr.begin(), arr.end(), cmp1);

    for (int i = 0; i < n; ++i) {
        if (s > 0) {
            s--;
            ans -= arr[i].a;
        } else {
            out << ans;
            return 0;
        }
    }

    out << ans;
}
