let () =
  let max = Scanf.scanf "%d\n" (fun a -> a) in

  let rec pow (x, y) =
    if y = 0 then 1 else x * pow (x, y - 1)
  in

  let rec f x n res = 
    if x = 1 then res else (
      let v = pow (x,n) in
      let res = (if v <= max && v > res then v else res) in
      (
        if v > max then
          f (x-1) 2 res
        else
          f (x) (n+1) res
      )
    )
  in

  print_endline (string_of_int (f max 2 1))
