X = int(eval(input()))

se = set(n**e for n in range(32) for e in range(2,11) if n**e <= X)



answer = max(se)

print(answer)

X = int(eval(input()))

S = set(n**e for n in range(32) for e in range(2,11) if n**e<=X)

print((max(S)))

X = int(eval(input()))
se = set(n**e for n in range(32) for e in range(2, 11) if n ** e <= X)
answer = max(se)
print(answer)

X = int(eval(input()))
S = set(n**e for n in range(32) for e in range(2, 11) if n ** e <= X)
print((max(S)))

-se = set(n**e for n in range(32) for e in range(2, 11) if n ** e <= X) -answer = max(se) -print(answer) +S = set(n**e for n in range(32) for e in range(2, 11) if n ** e <= X) +print((max(S)))