import sys

import os





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = int(sys.stdin.readline().rstrip())

    ret = 1

    for b in range(1, N):

        for p in range(2, N//2):

            if b ** p <= N:

                ret = max(ret, b ** p)



    print(ret)





if __name__ == '__main__':

    main()

import sys, os, math, bisect, itertools, collections, heapq, queue

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall

from decimal import Decimal

from collections import defaultdict



# import fractions



sys.setrecursionlimit(10000000)



ii = lambda: int(sys.stdin.buffer.readline().rstrip())

il = lambda: list(map(int, sys.stdin.buffer.readline().split()))

fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))

iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]



iss = lambda: sys.stdin.buffer.readline().decode().rstrip()

sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))

isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]



lcm = lambda x, y: (x * y) // math.gcd(x, y)

# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)



MOD = 10 ** 9 + 7

MAX = float('inf')





def main():

    if os.getenv("LOCAL"):

        sys.stdin = open("input.txt", "r")



    N = ii()

    if N == 1:

        print((1))

        exit()



    b, p = 2, 1

    ret = []

    while b ** p <= N:

        if b ** (p + 1) <= N:

            p += 1

            ret.append(b ** p)

        else:

            b += 1

            p = 1



    ret.sort(reverse=True)

    print((ret[0]))





if __name__ == '__main__':

    main()

import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = int(sys.stdin.readline().rstrip())
    ret = 1
    for b in range(1, N):
        for p in range(2, N // 2):
            if b**p <= N:
                ret = max(ret, b**p)
    print(ret)


if __name__ == "__main__":
    main()

import sys, os, math, bisect, itertools, collections, heapq, queue

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]
iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]
lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)
MOD = 10**9 + 7
MAX = float("inf")


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")
    N = ii()
    if N == 1:
        print((1))
        exit()
    b, p = 2, 1
    ret = []
    while b**p <= N:
        if b ** (p + 1) <= N:
            p += 1
            ret.append(b**p)
        else:
            b += 1
            p = 1
    ret.sort(reverse=True)
    print((ret[0]))


if __name__ == "__main__":
    main()

-import sys -import os +import sys, os, math, bisect, itertools, collections, heapq, queue + +# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall +from decimal import Decimal +from collections import defaultdict + +# import fractions +sys.setrecursionlimit(10000000) +ii = lambda: int(sys.stdin.buffer.readline().rstrip()) +il = lambda: list(map(int, sys.stdin.buffer.readline().split())) +fl = lambda: list(map(float, sys.stdin.buffer.readline().split())) +iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)] +iss = lambda: sys.stdin.buffer.readline().decode().rstrip() +sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split())) +isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)] +lcm = lambda x, y: (x * y) // math.gcd(x, y) +# lcm = lambda x, y: (x * y) // fractions.gcd(x, y) +MOD = 10**9 + 7 +MAX = float("inf") -    N = int(sys.stdin.readline().rstrip()) -    ret = 1 -    for b in range(1, N): -        for p in range(2, N // 2): -            if b**p <= N: -                ret = max(ret, b**p) -    print(ret) +    N = ii() +    if N == 1: +        print((1)) +        exit() +    b, p = 2, 1 +    ret = [] +    while b**p <= N: +        if b ** (p + 1) <= N: +            p += 1 +            ret.append(b**p) +        else: +            b += 1 +            p = 1 +    ret.sort(reverse=True) +    print((ret[0]))