#include <bits/stdc++.h>

using namespace std;

const int MX_SZ = 1e+5 + 42;

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

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

struct gr
{
    const bool operator() (int x, int y) const
    {
        return x > y;
    }
};

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;
    }
    multiset<int, gr> st;
    sort(a.begin(), a.end(), by_k);
    for (int i = 0; i < n; i++)
    {
        while (s > 0 and !st.empty() and a[i].second < *st.begin())
        {
            ans -= *st.begin();
            s--;
            st.erase(st.begin());
        }
        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;
        st.insert(a[i].first);
    }
    cout << ans;
}
