#include<bits/stdc++.h>

#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

#define f first
#define s second
#define int long long
#define pb push_back
#define ld long double

const int N = 5e5 + 10, mod = 1e9 + 7, inf = 1e15 + 10;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; cin >> t;
    while(t--){
        int a, b; cin >> a >> b;
        int ans = 0;
        if(b == 1)
            ++b, ++ans;
        int res = inf;
        for(int i = 0; i <= 40; ++i){
            int num = a, cnt = i;
            while(num)
                num /= (b + i), ++cnt;
            res = min(res, ans + cnt);
        }
        cout << res << "\n";
    }
}
