#include<bits/stdc++.h>
using namespace std;
#define inf 0x3f3f3f3f
#define ll long long
#define il inline
#define FR(a,b,c) for(int a=b;a<=c;++a)
#define memset(a,b) memset(a,b,sizeof a)
#define pb push_back
typedef unsigned long long ull;
const int N=1e4+10;
const ll mod=1e9+7;

int main(){
    int t;
    int a,b;
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&a,&b);
        int ans=inf;
        FR(i,0,100){
            if(b==1){
                b++;
                continue;
            }
            int x=a,cnt=0;
            while(x){
                cnt++;
                x/=b;
            }
            ans=min(ans,cnt+i);
            b++;
        }
        printf("%d\n",ans);
    }
    return 0;
}

