#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>

using namespace std;

ifstream in("castle.in");
ofstream out("castle.out");

bool cmp(pair <long long, long long> a, pair <long long, long long> b){
    return (a.first > b.first);
}

int main(){
    long long s, n, toatt = 0, us;
    vector <long long> a, k;
    vector <pair <long long, long long> > tos;
    in >> n >> s;
    a.resize(n);
    k.resize(n);
    for (int i = 0; i < n; i++){
        in >> a[i] >> k[i];
        toatt += a[i];
        us = a[i] / k[i];
        tos.push_back(make_pair(k[i], us));
        tos.push_back(make_pair(a[i] - us * k[i], 1));
    }
    sort(tos.begin(), tos.end(), cmp);
    for (int i = 0; i < n * 2; i++){
        toatt -= min(s, tos[i].second) * tos[i].first;
        s -= min(s, tos[i].second);
    }
    out << toatt;
}
