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

using namespace std;

typedef long long ll;

ll n, s, a[100001], k[100001], ans;

bool cmp(pair <ll, ll> a, pair <ll,  ll> b){
    return a > b;
}

bool cmp2(ll a, ll b){
    return a > b;
}

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