#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

pair < ll, ll > b[200050];

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    ios::sync_with_stdio(0);
    ll sum = 0;
    int n, m = 0;
    ll s;
    cin >> n >> s;
    for (int i = 0; i < n; i++) {
        ll a, k;
        cin >> a >> k;
        sum += a;
        b[m++] = make_pair(a % k, 1);
        b[m++] = make_pair(k, a / k);
    }
    sort(b, b + m);
    reverse(b, b + m);
    for (int i = 0; i < m; i++) {
        ll val = b[i].first, cnt = b[i].second;
        if (cnt >= s) {
            sum -= val * (s);
            break;
        }
        else {
            s -= cnt;
            sum -= cnt * val;
        }
    }
    cout << max(0ll, sum);
    return 0;
}
