let main () =
  let rec expi a b = if b = 1 then a else expi (a*a) (b-1) in
  let x = Scanf.scanf "%d\n" (fun a -> a) in
  let xs = ref [] in
  let before = ref 0 in
  let now = ref 0 in
  for i = 2 to int_of_float (sqrt (float_of_int x)) + 1 do
    let j = ref 1 in
    while !now <= x do
      j := !j + 1;
      before := !now;
      now := expi i !j;
    done;
    xs := !before :: !xs;
    before := 0;
    now := 0;
  done;
  xs := List.sort (fun a b -> (-1 * compare a b)) !xs;
  print_int @@ List.hd !xs

let _ = main ()
