import math A = int(input()) ans = A for i in range(2, 8): ans = min(ans, i*math.ceil(math.log(A,i))) print(ans)