a = int(input()) ans = 200 for i in range(2,200): n = i tmp = n for j in range(61): if tmp >= a: ans = min(ans,n*(j+1)) break else: tmp *= i print(ans)