#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cstdint>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <vector>

#define ll long long
using namespace std;

void solve() {
    ll a, b;
    cin >> a >> b;
    ll count = 0;
    ll ans = 1000000000;
    ll curr = 0;
    while (count < 50) {
        ll tmpA = a;
        ll tmpCount = 0;
        if(b + count == 1){
            count++;
            continue;
        }
        while (tmpA != 0) {
            tmpA /= (b + count);
            tmpCount++;
        }
        ans = min(ans, tmpCount + count);
        count++;
    }
    cout << ans << endl;
}

int main(){
    int t;
    cin >> t;
    while(t--)
        solve();
}
