def solve():

    x = int(eval(input()))

    if x < 4:

        return 1

    elif x < 8:

        return 4

    elif x < 9:

        return 8

    l = [i**j for i in range(1,x+1) for j in range(2,int(x**0.5)) if i**j<=x]

    return max(l)

        

if __name__ == '__main__':

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

l = [i**j for i in range(1,33) for j in range(2,10) if i**j <= x]

print((max(l)))
def solve():
    x = int(eval(input()))
    if x < 4:
        return 1
    elif x < 8:
        return 4
    elif x < 9:
        return 8
    l = [
        i**j for i in range(1, x + 1) for j in range(2, int(x**0.5)) if i ** j <= x
    ]
    return max(l)


if __name__ == "__main__":
    print((solve()))

x = int(eval(input()))
l = [i**j for i in range(1, 33) for j in range(2, 10) if i ** j <= x]
print((max(l)))

-def solve(): -    x = int(eval(input())) -    if x < 4: -        return 1 -    elif x < 8: -        return 4 -    elif x < 9: -        return 8 -    l = [ -        i**j for i in range(1, x + 1) for j in range(2, int(x**0.5)) if i ** j <= x -    ] -    return max(l) - - -if __name__ == "__main__": -    print((solve())) +x = int(eval(input())) +l = [i**j for i in range(1, 33) for j in range(2, 10) if i ** j <= x] +print((max(l)))