#include <bits/stdc++.h>

using namespace std;

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    int n, s;
    cin >> n >> s;
    vector<pair<int, int> > arr;
    long long ans = 0;
    for(int i=0;i<n;i++)
    {
        int a, k;
        cin >> a >> k;
        ans += a;
        if(k <= a)
        {
            arr.push_back({-k, a/k});
        }
        if(a%k)
            arr.push_back({-(a%k), 1});
    }
    sort(arr.begin(), arr.end());
    for(int i=0;i<arr.size();i++)
    {
        if(arr[i].second <= s)
        {
            s -= arr[i].second;
            ans -= -arr[i].first * 1ll * arr[i].second;
        }
        else
        {
            ans -= -arr[i].first * 1ll * s;
            s = 0;
        }
        if(!s)
            break;
    }
    cout << max(ans, 0ll);
    return 0;
}
