A = int(input()) N = 2 M = 1 x = N while x < A: M += 1 x *= N ans = N * M M = 2 N = int(A ** 0.5) while N * N < A: N += 1 ans = min(ans, N * M) N = 3 M = 1 x = N while x < A: M += 1 x *= N ans = min(ans, N * M) M = 3 N = int(A ** 0.333333) while N * N < A: N += 1 ans = min(ans, N * M) print(ans)