#include <bits/stdc++.h>

using namespace std;

int main(){
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    long long s;
    int n;
    cin >> n >> s;
    vector < pair <long long, long long> > k(n);
    set < pair<long long, int> > ost;
    for (int i = 0; i < n; i++)
        cin >> k[i].second >> k[i].first;
    sort(k.begin(), k.end());
    reverse(k.begin(), k.end());
    long long ans = 0;
    for (int i = 0; i < n; i++){
        while (ost.size() > 0 && s > 0 && k[i].first < (*ost.begin()).first){
            s--;
            ost.erase(*ost.begin());
        }
        if (s >= k[i].second / k[i].first){
            s -= (k[i].second / k[i].first);
            ost.insert(make_pair(k[i].second % k[i].first, i));
        }
        else{
            ans += (k[i].second - s*k[i].first);
            s = 0;
        }
    }
    while (ost.size() != 0){
        if (s == 0) ans += (*ost.begin()).first;
        else s--;
        ost.erase(*ost.begin());
    }
    cout << ans << "\n";
    return 0;
}
