#include <bits/stdc++.h>

using namespace std;

int main()
{
   int t;
   cin >> t;
   while(t--){
        int a;
        int b;
        cin >> a >> b;
        if(a==b){
            cout << 2 << endl;
        }
        else if(a<b) {
            cout << 1 << endl;
        }

        else {
                int mini=INT_MAX;
            for(int i=max(b,2);i<=b+30;i++){
                double k=a*1.0;
                double o=i*1.0;
            int p=log(k)/log(o);
            double z=(p+1)*1.0;

                if(pow(o,z)==k){
                    p++;
                }
            mini=min((p+i-b),mini);

            }
            cout << mini+1 << endl;
        }
   }
    return 0;
}
