#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <cstdlib>
using namespace std;

struct tp
{
    long long a, k;
};

long long n, s;
multiset <tp> a;

bool operator < (const tp &a, const tp &b)
{
    if (a.k != b.k)
    {
        return a.k > b.k;
    }

    return rand() % 2;
}

int main()
{
    ios_base::sync_with_stdio(false);
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> s;
    for (int i = 1; i <= n; i++)
    {
        long long a1, k1;
        cin >> a1 >> k1;
        a.insert({a1, min(k1, a1)});
    }

    while (s > 0 && a.size() > 0)
    {
        long long a1 = ((a.begin()) -> a);
        long long k1 = ((a.begin()) -> k);

        long long del1 = (a1 / k1) * k1;
        if (s < del1 / k1)
        {
            del1 -= s * k1;
            a.erase(a.begin());
            a.insert({del1, k1});

            s = 0;
        } else
        {
            s -= del1 / k1;
            a.erase(a.begin());
            if (a1 - del1 > 0)
            {
                a.insert({a1 - del1, a1 - del1});
            }
        }
    }

    long long ans = 0;
    for (auto it = a.begin(); it != a.end(); it++)
    {
        ans += (it -> a);
    }

    cout << ans << endl;
    return 0;
}
