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

void solve(){
    long long int a,b;
    cin>>a;
    cin>>b;
    long long int count=0;
    if(b>a){
    	cout<<"1"<<endl;
    	return;
    }
    if(a==b){
    	cout<<"2"<<endl;
    	return;
    }
    
    if(b==1){
    	count++;
    	b=b+1;
    }

    int lastc,currc;
    lastc=currc=1000000000;
    //cout<<"8**"<<endl;
    while(1){
    	currc=count;
    	long long int k=a;
    	while(k>0){
           currc++;
           k=k/b;
    	}
    	if(currc<=lastc){
    		lastc=currc;
    		b++;
    		count++;
    		continue;
    	}
    	if(currc>lastc){
    		cout<<lastc<<endl;
    		return;
    	}
    }
}

int main(){
	long long int t;
	cin>>t;
	while(t--){
		solve();
	}
}