let powers =
    let rec loop b v l =
        if v <= 1000 then loop b (v * b) (v :: l)
        else
            let b' = b + 1 in
            if b' * b' <= 1000 then loop b' (b' * b') l
            else l
    in 1 :: loop 2 4 []

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