#include <bits/stdc++.h>
using namespace std;
void io() { ios_base::sync_with_stdio(0), cin.tie(0); }
typedef long long ll;
typedef vector<int> vi;

void Case() {
  ll a, b;
  cin >> a >> b;
  int ans = 2147483647;
  for (int i = 0; i < 1000 && i < ans; i++) {
    int cur = i;
    ll x = b + i;
    if (x == 1)
      continue;
    ll ax = a;
    while (ax) {
      ax /= x;
      cur++;
    }
    ans = min(ans, cur);
  }
  cout << ans << "\n";
}

int main() {
  io();

  int T;
  while (cin >> T)
    while (T--)
      Case();

  return 0;
}