#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll loga(ll x, ll y)
{
    ll c=0;
    while(x)
    {
        x/=y;
        c++;
    }
    //c=log(x)/log(y);
    return c;

}
int main()
{
ll t; cin>>t; while(t--)
{
    ll a,b,k,mn=10000000000;
    cin>>a>>b;
  if(a<b) cout<<1<<endl;
  else{

 for(ll i=0;i<10000;i++){
        if(b+i==1) continue;
    k =loga(a,b+i);
    mn=min(mn,k+i);
}
cout<<mn<<endl;
}
}
}
