#include <iostream>
#include <cmath>

using namespace std;

int get(int a, int b) {
	int n;
	for (int i = 1; a > 0; i++) {
		a /= b;
		n = i;
	}
	return n;
}

int main() {
	int t;
	cin >> t;
	while (t--) {
		int a, b;
		cin >> a >> b;
		int initb = b;
		if (b > a) {
			cout << 1 << endl;
		}
		else if (b == a) {
			cout << 2 << endl;
		}
		else {
			if (b == 1) {
				b++;
			}
			int init = get(a, b) + b - initb;
			for (int i = b + 1; i <= b + 9; i++) {
				int pred = get(a, i) + i - initb;
				init = min(init, pred);
			}
			cout << init << endl;
		}
	}
	return 0;
}