#include using namespace std; typedef long long ll; typedef pair pii; typedef pair pll; #define MOD ll(1e9+7) #define all(x) (x).begin(),(x).end() #define dbg(x) cerr<<#x<<": "<> q; for(int i = 0; i < q; i++){ ll n, k; cin >> n >> k; ll num = 1; ll ans = 0; ll c = 1; while(num < n){ c *= k; num += c; ans++; } cout << ans << endl; } return 0; }