#include <iostream>
#include <cstdio>
#include <vector>
#include <set>

using namespace std;

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    int n, s;
    cin >> n >> s;
    vector <int> a(n), k(n);
    long long maxans = 0;
    for (int i = 0; i < n; ++i)
        cin >> a[i] >> k[i], maxans += a[i];

    set <pair <int, int> > to_remove;
    for (int i = 0; i < n; ++i)
        to_remove.insert(make_pair(-min(k[i], a[i]), i));

    while (s > 0 && maxans > 0)
    {
        //cerr << s << ' ' << maxans << endl;
        int i = to_remove.begin()->second;
        int f = -to_remove.begin()->first;
        //cerr << f << ' ' << i << endl << endl;
        if (f != k[i])
        {
            s--;
            maxans -= a[i];
            a[i] = 0;
            to_remove.erase(to_remove.begin());
        }
        else
        {
            int need = min(a[i] / k[i], s);
            a[i] -= need * k[i];
            maxans -= need * k[i];
            s -= need;
            to_remove.erase(to_remove.begin());
            if (a[i] > 0)
                to_remove.insert(make_pair(-min(k[i], a[i]), i));
        }
    }
    cout << maxans << endl;
}
