#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int N = 1e5 + 10;
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-8;

int main() {
    int t;
    cin>>t;
    while(t--){
        int a,b;
        scanf("%d %d",&a,&b);
        int ans = INF;
        for(int i = b;i<=b+50;i++){
            int sum = i-b;
            int x = a,y = i;
            if(i==1)    continue;
            while(x>y){
                x /= y;
                sum++;
            }
            if(x==y){
                sum+=2;
            }else{
                sum++;
            }
            ans = min(ans,sum);
        }
        printf("%d\n",ans);
    }
    return 0;
}