#include<bits/stdc++.h>
#define ll long long
#define st string
#define ld long double
#define ss second
#define ff first
using namespace std;
int main(){
    ll t, n, l = 0, r = 1e9, sum = 0, ans = 0, k, a, b;
    cin >> t;
    while(t--){
        sum = 1e9;
        int ok = 0;
        cin >> a >> b;
        if(b == 1){
            ok++;;
            b++;
        }
        for(int i = b; i <= b + 1000; i++){
            k = a;
            while(k > 0){
                k /= i;
                ans++;
            }
            sum = min(sum, ans + (i - b) + ok);
            ans = 0;
        }
        cout << sum << endl;
    }
    return 0;
}

