let rec pow e x = if x >= 1 then e * pow e (x - 1) else 1
    in
    let rec find_max e x s = if pow (e + 1) x >= pow e (x + 1) then (if pow (e + 1) x <= s then find_max (e + 1) x s else (if pow e (x + 1) <= s then find_max e (x + 1) s else pow e x))
                             else (if pow e (x + 1) <= s then find_max e (x + 1) s else (if pow (e + 1) x <= s then find_max (e + 1) x s else pow e x))
    in
    let s = ref 0 in
    Scanf.sscanf (read_line ()) "%d" (fun x -> s := x);
    print_int (find_max 1 1 !s); print_string "\n"