let rec iter a b f = if a >= b then () else (f a; iter (a+1) b f)
let () =
  Scanf.scanf "%d" @@ fun x ->
  let a = Array.make (x+1) false in
  a.(1) <- true;
  iter 2 (x+1) (fun b ->
    let rec loop v =
      if v > x then ()
      else (a.(v) <- true; loop (v*b))
    in loop (b*b));
  Array.mapi (fun i e -> i,e) a
  |> Array.fold_left (fun v (i,t) -> if t then i else v) 1
  |> Printf.printf "%d\n"