#include <bits/stdc++.h>

#define TASK "castle"
using namespace std;
typedef long long ll;
typedef long double ld;
const ll inf = numeric_limits<ll>::max();
const ll mod = 1000000007;
const ld eps = 1e-7;
const ll maxn = 123456;

pair<pair<ll, ll>, ll> mas[maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    if(strcmp(TASK,"")!=0)
    {
        freopen(TASK".in","r",stdin);
        freopen(TASK".out","w",stdout);
    }
#endif

    ll n, s;
    cin >> n >> s;
    ll all = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> mas[i].first.second >> mas[i].first.first;
        all += mas[i].first.second;
        mas[i].second = i;
    }
    sort(mas, mas + n, greater<pair<pair<ll, ll>, ll>>());
    priority_queue<ll> q;
    for (int i = 0; i < n && s > 0; i++)
    {
        while (s > 0 && !q.empty() && q.top() >= mas[i].first.first)
        {
            all -= q.top();
            q.pop();
            s--;
        }
        ll s2 = min(s,mas[i].first.second / mas[i].first.first);
        all -= s2*mas[i].first.first;
        s-=s2;
        q.push(mas[i].first.second % mas[i].first.first);
    }
    cout << all;
    return 0;
}