#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
int main(){
ll i,t,ans;cin>>t;while(t--){
    ll a , b, n;cin>>a>>b;
    ll cnt  = 0;
     n = sqrt(a);
     ans = 10000000000;
    for(i=0;i<=n;i++){
        cnt = i;
        if(b == 1 && i ==0)continue;

        ll a1 = a;
        while(a1>0){
            a1/=(b+i);cnt++;
        }
        ans = min(ans, cnt);
    }
    cout<<ans<<"\n";
}

return 0;
}
