#素因数分解して列挙する関数、約数列挙ではない！

from collections import Counter

def factorize(n):

  b = 2

  fct = []

  while b * b <= n:

    while n % b == 0:

      n //= b

      fct.append(b)

    b = b + 1

  if n > 1:

    fct.append(n)

  f = list(Counter(fct).values())

  if 1 not in f and len(set(f))==1:

    return True

  return False



X = int(eval(input()))

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

  f = factorize(i)

  if f==True or i==1:

    print(i)

    break
def solve():

  ans = 0

  X = int(eval(input()))

  lis = [False]*(X+1)

  lis[1] = True

  for b in range(2,X+1):

    p = 2

    while b**p<=X:

      lis[b**p] = True

      p += 1

  for i in range(X,-1,-1):

    if lis[i]==True:

      return i

print((solve()))
# 素因数分解して列挙する関数、約数列挙ではない！
from collections import Counter


def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    f = list(Counter(fct).values())
    if 1 not in f and len(set(f)) == 1:
        return True
    return False


X = int(eval(input()))
for i in range(X, 0, -1):
    f = factorize(i)
    if f == True or i == 1:
        print(i)
        break

def solve():
    ans = 0
    X = int(eval(input()))
    lis = [False] * (X + 1)
    lis[1] = True
    for b in range(2, X + 1):
        p = 2
        while b**p <= X:
            lis[b**p] = True
            p += 1
    for i in range(X, -1, -1):
        if lis[i] == True:
            return i


print((solve()))

-# 素因数分解して列挙する関数、約数列挙ではない！ -from collections import Counter +def solve(): +    ans = 0 +    X = int(eval(input())) +    lis = [False] * (X + 1) +    lis[1] = True +    for b in range(2, X + 1): +        p = 2 +        while b**p <= X: +            lis[b**p] = True +            p += 1 +    for i in range(X, -1, -1): +        if lis[i] == True: +            return i -def factorize(n): -    b = 2 -    fct = [] -    while b * b <= n: -        while n % b == 0: -            n //= b -            fct.append(b) -        b = b + 1 -    if n > 1: -        fct.append(n) -    f = list(Counter(fct).values()) -    if 1 not in f and len(set(f)) == 1: -        return True -    return False - - -X = int(eval(input())) -for i in range(X, 0, -1): -    f = factorize(i) -    if f == True or i == 1: -        print(i) -        break +print((solve()))