#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
typedef pair <int,int> ii;

int main() {
    int t;
    cin >> t;
    while (t--) {
        int a,b;
        cin >> a >> b;
        int mn=1e9+3;
        for (int i=max(2,b); i<=1e9+3; i++) {
            int cnt=i-b;
            int tmp=a;
            while (tmp>0) {
                tmp/=i;
                cnt++;
            }
            if (cnt>mn) break;
                else mn=cnt;
        }
        cout << mn << "\n";
    }
}
