#include <bits/stdc++.h>
using namespace std;
#define DB(v) cerr << #v << ' ' << v << endl
#define sz(v) int(v.size())
#define fi first
#define se second

typedef long long i64;
typedef pair <int,int> pii;

struct zone
{
    int attack, defense;
    bool operator < (const zone &A) const{
        int one = min(attack, defense), two = min(A.attack, A.defense);
        if(one == two) {
            if(attack == A.attack)
                return defense < A.defense;
            return attack < A.attack;
        }
        return one < two;
    }
    bool operator == (const zone & A) const {
        return (A.attack == attack && A.defense == defense);
    }
};


int n, s;

multiset <zone> alive;

i64 ans = 0;

void prepare() {
    cin >> n >> s;
    zone x;
    for(int i = 0;i < n; ++i) {
        cin >> x.attack >> x.defense;
        ans += x.attack;
        alive.insert(x);
    }
}

int main()
{
#ifdef HOME
    freopen("input.txt","r", stdin);
#else
    freopen("castle.in","r",stdin);
    freopen("castle.out","w",stdout);
#endif
    ios::sync_with_stdio(NULL); cin.tie(NULL);
    prepare();
    while(s > 0) {
        zone x = *(--alive.end());
        if(x.attack == 0) break;
        int need = max(x.attack / x.defense, 1);
        int add = min(need, s);
        i64 defeat = add * 1LL * x.defense;
        ans -= min(defeat, x.attack * 1LL);
        s -= add;

        alive.erase(alive.find(x));
        int rev = max(x.attack - defeat, 0LL);
        x.attack = rev;
        alive.insert(x);
    }
    cout << ans;
    return 0;
}
