#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define all(x)  (x).begin(), (x).end()
using namespace std;
 
int solve(int a,int b)
{
  if(a<=0)
    return 0;
  return min(1+solve(a/b,b), 2+solve(a/(b+1),b+1));
} 
signed main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  int t;
  cin>>t;
  while(t--)
  {
    int a,b;
    cin>>a>>b;
    int ans=1e9;
    for(int i=0;i<100;i++)
    {
      int x=b+i;
      int temp= i;
      int xa=a;
      int xb=x;
      for(int j=0;j<100;j++)
      {
        if(xa<=0)
          break;
        xa/=xb;
        temp++;
      } 
      ans=min(ans,temp);
    }
    cout<<ans<<endl;
  }
}