#include <bits/stdc++.h>
using namespace std;

void solve();

#define ll long long
int n, m, k;
vector<int> a;
vector<vector<pair<ll, ll>>> adj;
vector<int> b;

ll ans = INT_MAX;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t;
    cin >> t;

    while (t--)
        solve();
}

void solve()
{
    ans = INT_MAX;
    int a, b;
    cin >> a >> b;

    int k = 0;

    if (b == 1)
    {
        k = 1;
        b = 2;
    }

    for (int i = 0; i <= 30; i++)
    {
        int m = b + i;
        int n = a;
        ll local = i;
        while (n)
        {
            n /= m;
            local++;
        }
        // cout << m << ' ' << local << '\n';
        ans = min(ans, local);
    }
    cout << ans + k << '\n';
    // cout << '\n';
}
