#include <bits/stdc++.h>

using namespace std;

const int MX_SZ = 1e+5 + 42;

inline bool by_k(const pair<int, int> &a, const pair<int, int> &b)
{
    return a.second > b.second;
}

inline bool by_rem(const pair<int, int> &a, const pair<int, int> &b)
{
    return a.first > b.first;
}

int main()
{
    ios_base::sync_with_stdio(false);
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    int n;
    long long s;
    cin >> n >> s;
    vector<pair<long long, long long>> a;
    long long ans = 0;
    for (int i = 0; i < n; i++)
    {
        pair<int, int> t;
        cin >> t.first >> t.second;
        a.push_back(t);
        ans += t.first;
    }
    sort(a.begin(), a.end(), by_k);
    for (int i = 0; i < n; i++)
    {
        long long cr = min(s, a[i].first / a[i].second);
        ans -= cr * a[i].second;
        a[i].first -= cr * a[i].second;
        s -= cr;
    }
    sort(a.begin(), a.end(), by_rem);
    for (int i = 0; i < n; i++)
    {
        if (s == 0)
        {
            break;
        }
        s--;
        ans -= a[i].first;
    }
    cout << ans;
}
