(* O(√p) *)
let n, p = Scanf.scanf " %d %d" @@ fun a b -> a, b
let factorize_primes n =
  let rec f acc c d m =
    if d > m || d * d > n then
      List.rev @@ if c > 0 then (d, c) :: acc else if m > 1 then (m, 1) :: acc else acc
    else
      if m mod d = 0 then f acc (c + 1) d @@ m / d
      else f (if c > 0 then (d, c) :: acc else acc) 0 (d + 1) m in
  f [] 0 2 n
let rec pow b n = if n <= 0 then 1 else b * pow b (n - 1)
let ps = factorize_primes p
let _ = List.fold_left (fun acc (b, c) -> acc * pow b (c / n)) 1 ps |> Printf.printf "%d\n"