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

using namespace std;

int main() {
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    long long n, s;
    cin >> n >> s;
    pair<long long, long long> a[n];
    for (long long i = 0; i < n; i++) {
        cin >> a[i].second >> a[i].first;
        a[i].first *= -1;
    }
    sort(a, a + n);
    for (long long i = 0; i < n; i++) {
        a[i].first *= -1;
        if (s >= a[i].second / a[i].first) {
            s -= a[i].second / a[i].first;
            a[i].second %= a[i].first;
        } else {
            a[i].second -= a[i].first * s;
            s = 0;
        }
        //cout << a[i].second << ' ' << a[i].first << ' ' << s << endl;
        if (s >= 1 && i < n - 1 && a[i].second > -a[i + 1].first) {
            s--;
            a[i].second = 0;
        }
        //cout << a[i].second << ' ' << a[i].first << ' ' << s << endl;
        a[i].first = 0;
        a[i].second *= -1;
    }
    sort(a, a + n);
    for (long long i = 0; i < n; i++) {
        a[i].second *= -1;
        if (s > 0) {
            a[i].second = 0;
            s--;
        }
    }
    long long ans = 0;
    for (long long i = 0; i < n; i++) {
        ans += a[i].second;
    }
    cout << ans;
}
