#include <bits/stdc++.h>

using namespace std;

pair<long long, long long> a[100000];
pair<long long, long long> b[100000];
long long c[100000];

int main()
{
    ifstream cin("castle.in");
    ofstream cout("castle.out");
    int n, s;
    cin >> n >> s;
    long long sum = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i].first >> a[i].second;
        sum += a[i].first;
        b[i] = {a[i].second, a[i].first / a[i].second};
        c[i] = a[i].first % a[i].second;
    }

    sort(b, b + n);
    sort(c, c + n);
    reverse(b, b + n);
    reverse(c, c + n);
    int i = 0, j = 0;
    long long ans = 0;

    while (s > 0 && (i < n || j < n)){
        if (j == n || b[i].first > c[j]){
            if (b[i].second <= s){
                ans += b[i].second * b[i].first;
                s -= b[i].second;
                b[i].second = 0;
                i++;
                continue;
            }
            ans += s * b[i].first;
            s = 0;
        }
        else{
            ans += c[j];
            j++;
            s--;
        }
    }

    cout << sum - ans;
    return 0;
}
