let main () =
  let x = Scanf.scanf "%d\n" (fun a -> a) in
  let ans = BatArray.make (x+1) false in
  ans.(1) <- true;
  for i = 2 to x do
    let n = ref @@ i * i in
    while !n <= x do
      ans.(!n) <- true;
      n := !n * i;
    done;
  done;
  for i = x downto 1 do
    if ans.(i) then (print_int i; exit 0)
  done;;

let _ = main ()
