#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll T,a,b;
int main(){
	cin>>T;
	while(T--){
		cin>>a>>b;
		ll ans=0x3f3f3f3f;
		for(int i=0;i<=1000;i++){
			ll minn=i;
			ll B=b+i;
			if(B==1)minn++,B++;
			ll A=a;
			while(A){
				A/=B;
				minn++;
			}	
			ans=min(minn,ans);
		}
		
		cout<<ans<<endl;
	}
	return 0;
}
