#include <bits/stdc++.h>

using namespace std;

int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    cin.sync_with_stdio(false);
    cout.sync_with_stdio(false);
    cin.tie(0);
    long long t;
    int n;
    cin >> n >> t;
    set<pair<long long, pair<long long, int> > > s;
    long long ans = 0;
    for (long long i = 0; i < n; i++)
    {
        long long a, b;
        cin >> a >> b;
        ans += a;
        s.insert({-min(b, a), {-a, i}});
    }
    while (t > 0 && s.size() > 0)
    {
        auto q = s.begin();
        long long w = q->first;
        long long e = q->second.first;
        int qwe = q->second.second;s
        w *= -1;
        e *= -1;
        s.erase(q);
        long long a = min(t, e / w);
        ans -= a * w;
        e -= a * w;
        t -= a;
        if (e > 0)
            s.insert({-min(e, w), {-e, t}});
    }
    cout << ans << endl;
    return 0;
}
