A = int(input()) X = float('inf') for N in range(2, 8): for M in range(1, 40): if N ** M >= A: X = min(X, N*M) print(X)