let rec h x i = if x mod i = 0 then h (x/i) i else if x = 1 then true else false
let rec g x i = if x = i then false else if x mod i = 0 && h x i then true else g x (i+1)
let rec f x = if x = 1 then 1 else if g x 2 then x else f (x-1)
let () =
let x = Scanf.scanf "%d\n" (fun x -> x) in
Printf.printf "%d\n" (f x)