#include<cstdio>
using namespace std;
int f(long long a,long long b){
	long long p = b;
	int i = 1;
	while(p<=a){
		p = p * b;
		i++;
	}
	return i;
}
int main(){
	int t,num;
	long long a,b;
	scanf("%d",&t);
	while(t--){
		scanf("%lld%lld",&a,&b);
		num = 0;
		if(b==1){
			b++;
			num++;
		}
		while(f(a,b)>f(a,b+1)){
			b++;
			num++;
		}
		num += f(a,b);
		printf("%d\n",num);
	}
	return 0;
} 