#include <bits/stdc++.h>

#define int long long

using namespace std;

int32_t main()
{
    ifstream cin("castle.in");
    ofstream cout("castle.out");
    int n, s;
    cin >> n >> s;
    pair<int, int> arr[n];
    int ans = 0;
    for (auto &p : arr)
    {
        cin >> p.second >> p.first;
        ans += p.second;
    }
    int arr2[n];
    sort(arr, arr + n);
    reverse(arr, arr + n);
    for (int i = 0; i < n; i++)
    {
        int os = s;
        s -= arr[i].second / arr[i].first;
        if (s < 0)
            s = 0;
        int ds = os - s;
        ans -= ds * arr[i].first;
        arr2[i] = arr[i].second - ds * arr[i].first;
    }
    sort(arr2, arr2 + n);
    reverse(arr2, arr2 + n);
    for (int i : arr2)
    {
        if (s > 0)
        {
            s--;
            ans -= i;
        }
    }
    cout << ans;
    return 0;
}
