#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <set>

using namespace std;

pair<long long, long long> arr[100005];

set<pair<long long, long long> > s1;

int main()
{
    freopen("in.in", "r", stdin);
    //freopen("castle.out", "w", stdout);

    long long n, s;
    cin >> n >> s;

    long long ans = 0;
    for(long long i = 0; i < n; i++)
    {
        cin >> arr[i].first >> arr[i].second;
        ans += arr[i].first;
        s1.insert(make_pair(arr[i].second, arr[i].first / arr[i].second));
        s1.insert(make_pair(arr[i].first % arr[i].second, 1));
    }

    for(set<pair<long long, long long> >::reverse_iterator it = s1.rbegin(); it != s1.rend(); it++)
    {
        long long c = it->second;
        if(c > s) c = s;
        ans -= it->first * c;
        s -= c;
    }

    cout << ans << endl;







    return 0;
}
