#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll t;
	cin>>t;
	while(t--){
		ll a,b;
		cin>>a>>b;
		ll ans=0x3f3f3f3f;
		ll u=0;
		ll p=0;
		if(a==b){
			cout<<"2"<<endl;
			continue;
		}
		if(b==1) u++,b=2;
		
		for(ll i=b;i<=a;i++){
			ll aa=a;
			while(aa){
				p++;
				aa=aa/i;
			//	cout<<"\n"<<a<<"\n";
			}	
			p+=u;
			u++;
			ans=min(p,ans);
		//	cout<<ans<<"\n"; 
		if(ans!=p)break;
			p=0;
		}
		if(ans==0x3f3f3f3f)ans=1;
		cout<<ans<<"\n";
	}
	return 0;
}