#include <bits/stdc++.h>

typedef long long int ll;
typedef long double ld;
typedef unsigned long long ull;

#define RESET(a, b) memset(a, b, sizeof(a))
int INF = 1000000005;
long long INFF = 1000000000000000005LL;

using namespace std;


struct monster {
    ll health, attack_power;
};

int main() {



    ll t;
    cin>>t;
    while(t--)
    {
        ll a,b;
        cin>>a>>b;
        ll ans=INFF;
        if(a==1)
        {
            if(b!=1)
            {
                cout<<1<<endl;
            }
            else
            {
                cout<<"2\n";
            }
            continue;
        }
        if(b>a)
        {
            cout<<"1\n";
            continue;
        }



        for(int i=0;i<=100000;i++)
        {
            ll x=b+i;
            ll y=a;
            ll cnt=i;
            bool ok=0;
            while(y and x!=1)
            {
                ok=1;
                y=y/x;
                cnt++;
            }

            //cout<<x<<endl;
            if(ok)ans=min(ans,cnt);
        }
        cout<<ans<<endl;


    }



    //ctime;
    return 0;
}