# ABC097B - Exponential

def main():

    X = int(eval(input()))

    cand = {1}

    for i in range(2, int(X ** 0.5) + 1):

        p = 2

        while i ** p <= X:

            cand.add(i ** p)

            p += 1

    ans = max(cand)

    print(ans)





if __name__ == "__main__":

    main()
# ABC097B - Exponential

def main():

    X = int(eval(input()))

    cand = [1]

    for i in range(2, int(X ** 0.5) + 1):

        p = 2

        while i ** p <= X:

            cand.append(i ** p)

            p += 1

    ans = max(cand)

    print(ans)





if __name__ == "__main__":

    main()
# ABC097B - Exponential
def main():
    X = int(eval(input()))
    cand = {1}
    for i in range(2, int(X**0.5) + 1):
        p = 2
        while i**p <= X:
            cand.add(i**p)
            p += 1
    ans = max(cand)
    print(ans)


if __name__ == "__main__":
    main()

# ABC097B - Exponential
def main():
    X = int(eval(input()))
    cand = [1]
    for i in range(2, int(X**0.5) + 1):
        p = 2
        while i**p <= X:
            cand.append(i**p)
            p += 1
    ans = max(cand)
    print(ans)


if __name__ == "__main__":
    main()

-    cand = {1} +    cand = [1] -            cand.add(i**p) +            cand.append(i**p)