let exps_base_n_less_than x n =
  let rec aux acc =
    if acc <= x then acc :: (aux @@ ( * ) n acc)
    else [] in
  aux @@ ( * ) n n

let exp_less_than_dec x =
  let rec exps n =
    if n = 1 then []
    else exps_base_n_less_than x n  @ exps @@ pred n
  in
  List.filter (fun n -> n <= x) @@ exps x
  |> List.sort compare
  |> List.rev

let main () =
  let x = Scanf.scanf "%d" (fun x -> x) in
  exp_less_than_dec x
  |> List.hd
  |> print_int

let () = main ()
