def main():

    X = int(eval(input()))

    ans = []

    for b in range(1, 100):

        for p in range(2, 10):

            if b**p <= X:

                ans.append(b**p)

    print((max(ans)))





if __name__ == '__main__':

    main()

def main():

    N = int(eval(input()))

    ans = set()

    for a in range(N+1):

        for b in range(2, 31):

            if a**b > N:

                continue

            ans.add(a**b)

    print((max(ans)))





if __name__ == '__main__':

    main()

def main():
    X = int(eval(input()))
    ans = []
    for b in range(1, 100):
        for p in range(2, 10):
            if b**p <= X:
                ans.append(b**p)
    print((max(ans)))


if __name__ == "__main__":
    main()

def main():
    N = int(eval(input()))
    ans = set()
    for a in range(N + 1):
        for b in range(2, 31):
            if a**b > N:
                continue
            ans.add(a**b)
    print((max(ans)))


if __name__ == "__main__":
    main()

-    X = int(eval(input())) -    ans = [] -    for b in range(1, 100): -        for p in range(2, 10): -            if b**p <= X: -                ans.append(b**p) +    N = int(eval(input())) +    ans = set() +    for a in range(N + 1): +        for b in range(2, 31): +            if a**b > N: +                continue +            ans.add(a**b)