x = int(eval(input()))



for i in range(x, 0, -1):

    for j in range(2, i):

        s = i

        while s%j == 0:

            t = s % j

            s = s // j

            if s == 1 and t == 0:

                print(i)

                exit()       

print((1))
x = int(eval(input()))

ans = [1]

for i in range(2, x):

    for j in range(2,11):

        ad = i**j

        if ad > x:

            break

        ans.append(ad)

print((max(ans)))
x = int(eval(input()))
for i in range(x, 0, -1):
    for j in range(2, i):
        s = i
        while s % j == 0:
            t = s % j
            s = s // j
            if s == 1 and t == 0:
                print(i)
                exit()
print((1))

x = int(eval(input()))
ans = [1]
for i in range(2, x):
    for j in range(2, 11):
        ad = i**j
        if ad > x:
            break
        ans.append(ad)
print((max(ans)))

-for i in range(x, 0, -1): -    for j in range(2, i): -        s = i -        while s % j == 0: -            t = s % j -            s = s // j -            if s == 1 and t == 0: -                print(i) -                exit() -print((1)) +ans = [1] +for i in range(2, x): +    for j in range(2, 11): +        ad = i**j +        if ad > x: +            break +        ans.append(ad) +print((max(ans)))