#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 1791791791791791791ll

int main()
{
#ifndef LOCAL
    freopen("castle.in", "r", stdin);
    freopen("castle.out", "w", stdout);
#endif
    int n; ll s;
    cin >> n >> s;
    vector<ll> a(n), k(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> k[i];
    vector<int> ind(n);
    for (int i = 0; i < n; i++)
        ind[i] = i;
    sort(ind.begin(), ind.end(), [&](const int& i, const int& j) -> bool {return k[i] > k[j];});

    ll l = -1, r = INF;
    while (l < r - 1)
    {
        ll mid = (l + r) >> 1;
        ll _mid = mid;

        ll _s = 0;
        for (int i = 0; i < n; i++)
        {
            if (mid > a[ind[i]])
                mid -= a[ind[i]];
            else
            {
                ll x = (a[ind[i]] - mid + k[ind[i]] - 1) / k[ind[i]];
                mid -= (a[ind[i]] - x * k[ind[i]]);
                _s += x;
            }
        }

        if (_s > s)
            l = _mid;
        else
            r = _mid;
    }

    cout << r << endl;

    return 0;
}
