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

using namespace std;

vector <pair <long long, long long> > a;
vector <long long> k;

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

int main()
{
    ifstream in;
    ofstream out;
    in.open("castle.in");
    out.open("castle.out");
    long long n, s, b, c, su = 0, b1, c1;
    in >> n >> s;
    for (long long i = 0; i < n; i++) {
        in >> b >> c;
        su += b;
        b1 = b % c;
        a.push_back(make_pair(c, b - b1));
        if (b1 != 0) {
            a.push_back(make_pair(b1, b1));
        }
    }
    sort(a.begin(), a.end(), cmp);
    long long i = 0, f = 0;
    while (i < a.size() && s > 0) {
        if (s >= a[i].second / a[i].first) {
            su -= a[i].second;
            s = s - a[i].second / a[i].first;
        }
        else {
            su -= a[i].first * s;
            s = 0;
        }
        i++;
    }
    out << su;
    return 0;
}
