let powers =
    let rec powers_sub b k =
        if k > 1000 then []
        else k :: powers_sub b (k * b)
    in
    let rec loop b =
        if b > 1000 then []
        else (powers_sub b (b * b)) @ loop (b + 1)
    in
    1 :: loop 2

let () =
    let x = read_int () in
    List.filter ((>) x) powers
    |> List.fold_left max 1
    |> string_of_int
    |> print_endline
