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

using namespace std;

typedef long long ll;
ll s, n, a, k, ans;

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    cin >> n >> s;
    vector <pair <ll, ll> > v;
    set <pair <ll, ll> > s1;
    for (int i = 0; i < n; i++){
        cin >> a >> k;
        v.push_back(make_pair(-k, a));
        ans += a;
    }
    sort(v.begin(), v.end());
    for (int i = 0; i < n; i++){
        k = -v[i].first, a = v[i].second;
        while (!s1.empty() && s > 0 && (*s1.begin()).first < -k){
            ans += (*s1.begin()).first;
            s1.erase((*s1.begin()));
            s--;
        }
        ll t = min(s, a / k);
        s -= t;
        ans -= k * t;
        if (t * k != a)
            s1.insert(make_pair(t * k - a, i));
    }
    while (s > 0 && !s1.empty()){
        ans += (*s1.begin()).first;
        s--;
        s1.erase((*s1.begin()));
    }
    cout << ans << endl;
    return 0;
}
