#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main() {
  ll t;
  cin >> t;
  while (t--) {
    ll a, b;
    cin >> a >> b;
    ll ans = 100000000;
    bool f = 0;
    if (b == 1) {
      b++;
      f = 1;
    }
    rep(i, 1000) {
      ll cnt = 0;
      ll na = a, nb = b + i;
      while (na) {
        na /= nb;
        cnt++;
      }
      ans = min(ans, cnt + i);
    }
    if (f) ans++;
    cout << ans << endl;
  }
  return 0;
}
