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 s = 1 || s = 2 || s = 3 then 1
      else
        (if pow e (x+1) <= s then find_max e (x+1) s else (if pow (e+1) 2 <= s then find_max (e+1) 2 s else pow e x))
    in
    let s = ref 0 in
    Scanf.sscanf (read_line ()) "%d" (fun x -> s := x);
    print_int (find_max 2 2 !s); print_string "\n"