open Batteries

let sqrt_int x = int_of_float @@ sqrt @@ float_of_int x

let pow_below n x =
  let rec aux acc  =
    if acc > x then []
    else
      acc :: (aux @@ ( * ) n acc)
  in
  aux 1

let lower_than x =
  let num_exp_below_1000 =
    let rec aux n =
      if n =1 then
        [1]
      else
        (pow_below n 1000) @ (aux @@ pred n)
    in
    let num = sqrt_int 1000 in
    List.sort compare @@ aux num in
  List.filter (fun n -> n <= x) num_exp_below_1000

let main () =
  int_of_string @@ input_line stdin
  |> lower_than
  |> List.rev
  |> List.hd
  |> print_int

let () = main ()
