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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--)
    {
        ll int a,b;
        cin>>a>>b;
        ll int ans=INT_MAX , count=0;
        for(ll int i =0;i*i<=a;i++)
        {
            if(b==1 && i==0)
            continue;
            count=i;
            ll int tempa=a;
            while(tempa)
            {
                tempa/=(b+i);
                count++;
            }
            ans=min(count,ans);
        }
        cout<<ans<<'\n';
    }
    
    return 0;
}