#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define s second
#define f first
 
int main()
{
    #ifndef LOCAL_DEBUG
    freopen("castle.in", "rt", stdin);
    freopen("castle.out", "wt", stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, s, counter = 0, a, k;
    cin >> n >> s;
    vector < pair < int, int > > a1(n);
    for (auto& x : a1)
    {
        cin >> x.s >> x.f;
    }
    set < int > count;
    sort(a1.rbegin(), a1.rend());
    for (int i = 0; i < n; i++)
    {
        a = a1[i].s, k = a1[i].f;
        counter += a;
        while (s > 0 && count.size() > 0 &&  k < *(count.rbegin()))
        {
            s--;
            counter -= *(count.rbegin());
            auto x = count.end();
            x--;
            count.erase(x);
        }
        if (a % k)
            count.insert(a % k);
        counter -= min(s * k, a - a % k);
        s -= min(s, a / k);
    }
    cout << counter << endl;
    return 0;
}
