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


using namespace std;


vector<int> make_vector(int a, int b){
    vector<int> s(2);
    s[0] = a;
    s[1] = b;
    return s;
}

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    int n, sum;
    cin >> n >> sum;
    vector<vector<int> > s(n);
    set<vector<int> > lst;
    int answer = 0;
    for (int i = 0; i < n; i++){
        s[i].resize(2);
        cin >> s[i][1] >> s[i][0];
        lst.insert(make_vector(-s[i][0], s[i][1]));
        answer += s[i][1];
    }
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    while (sum > 0 && answer > 0){
        vector<int> a = *(lst.begin());
        a[0] = -a[0];
        if (a[0] * sum >= a[1]){
            sum -= a[1] / a[0];
            answer -= a[1] - a[1] % a[0];
            a[1] %= a[0];
            a[0] = a[1];
            lst.erase(*lst.begin());
            lst.insert(a);
        }
        else{
            answer -= sum * a[0];
            break;
        }
    cout << answer << endl;
    return 0;
}

