from sys import maxsize a = int(input()) ans = maxsize for n in [2, 3]: m = 1 while n**m < a: m += 1 ans = min(ans, m * n) print(ans)