#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;
}


void print(vector<int> s){
    for (int i = 0; i < s.size(); i++)
        cout << s[i] << " ";
    cout << endl;
}


int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    int n;
    long long summa;
    cin >> n >> summa;
    vector<vector<long long> > s(n);
    long long answer = 0;
    for (int i = 0; i < n; i++){
        s[i].resize(2);
        cin >> s[i][1] >> s[i][0];
        s[i][0] = min(s[i][0], s[i][1]);
        answer += s[i][1];
    }
    while (summa > 0 && answer > 0){
        int x = 0;
        for (int j = 0; j < n; j++)
            if (s[x][0] < s[j][0])
                x = j;
        if (summa * s[x][0] >= s[x][1]){
            summa -= s[x][1] / s[x][0];
            answer = answer - s[x][1] + s[x][1] % s[x][0];
            s[x][1] %= s[x][0];
            s[x][0] = s[x][1];
        }
        else{
            answer -= summa * s[x][0];
            break;
        }
    }
    cout << answer;
    return 0;
}

