#include<bits/stdc++.h>

using namespace std;

typedef long long lint;

#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define rs resize
#define cont continue
#define ret return
#define ins insert
#define era erase
#define brk break
#define asg assign
#define all(x) x.begin(),x.end()
#define mk make_pair

int n, s;
vector<int> a, k;
set<pair<int, int>, greater<pair<int, int> > > st;
lint ans = 0ll;

const string fname = "castle";

int main(){
    string fin = fname + ".in";
    string fout = fname + ".out";
    freopen(fin.c_str(), "r", stdin);
    freopen(fout.c_str(), "w", stdout);
    scanf("%d%d", &n, &s);
    a.rs(n); k.rs(n);
    F(i, 0, n){
        scanf("%d", &a[i]);
        ans += a[i];
        scanf("%d", &k[i]);
        st.insert(mk(min(a[i], k[i]), i));
    }
    while(!st.empty()){
        int i = st.begin()->second;
        st.era(st.begin());
        int hm = max(1, a[i]/k[i]);
        ans -= min(s, hm) * 1ll * min(a[i], k[i]);
        s = max(0, s - hm);
        if(s == 0)
            brk;
        if(a[i] > k[i] && a[i]%k[i] != 0){
            st.ins(mk(a[i]%k[i], i));
            a[i] %= k[i];
        }
    }
    printf("%lld", ans);
    ret 0;
}
