#include <bits/stdc++.h>
using namespace std;


int main()
{
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    long long n, s;
    cin >> n >> s;
    long long ans = 0;
    vector< pair<long long, long long> > wall(n);
    for (long long i = 0; i < n; ++i)
    {
        cin >> wall[i].second >> wall[i].first;
        ans += wall[i].second;
    }
    sort(wall.begin(), wall.end());
    reverse(wall.begin(), wall.end());
    for (long long i = 0; i < n; ++i)
    {
        if (s > 0)
        {
            if (wall[i].second / wall[i].first <= s)
            {
                s -= wall[i].second / wall[i].first;
                long long t = (wall[i].second / wall[i].first) * wall[i].first;
                ans -= t;
                wall[i].second -= t;
            }
            else
            {
                long long t = wall[i].first * s;
                ans -= t;
                wall[i].second -= t;
                s = 0;
            }
            swap(wall[i].first, wall[i].second);
        }
    }
    sort(wall.begin(), wall.end());
    reverse(wall.begin(), wall.end());
    for (long long i = 0; i < n; ++i)
    {
        if (s > 0)
        {
            if (wall[i].first > 0)
            {
                --s;
                ans -= wall[i].first;
            }
        }
    }
    cout << ans << endl;
    return 0;
}
