def check(n, k):
cnt = 0
while n > 0:
if((cnt == 0 and n % k != 1) or cnt > 3):
return False
n //= k
cnt += 1
return (cnt == 3)
N, K = 325, 6
while(not(check(N, K))):
K += 1
print(K)
def check(n, k):
cnt = 0
while n > 0:
if((cnt == 0 and n % k != 1) or cnt > 3):
return False
n //= k
cnt += 1
return (cnt == 3)
N, K = 325, 6
while(not(check(N, K))):
K += 1
print(K)