(* O(√x log x) *)
let x = read_int ()
let rec f acc n = if acc * n > x then acc else f (acc * n) n
let b = ref 2
let ans = ref 1
let _ =
  if x > 1 then while !b * !b <= x do ans := max !ans @@ f !b !b; incr b done;
  Printf.printf "%d\n" !ans