let factorize n =
  let rec f c d x =
    if x = 1 then if c > 0 then [(c, d)] else []
    else if c = 0 && d * d > x then [(1, x)]
    else if x mod d = 0 then f (c+1) d (x/d)
    else if c > 0 then (c, d) :: f 0 (d+1) x else f 0 (d+1) x
  in
  f 0 2 n

let rec pow_int a n =
  if n = 0 then 1
  else if n mod 2 = 1 then a * pow_int a (n-1)
  else let h = pow_int a (n/2) in h * h

let () =
  Scanf.scanf "%d %d" @@ fun n p ->
  factorize p
  |> List.fold_left (fun ac (c, d) -> ac * pow_int d (c/n)) 1
  |> Printf.printf "%d\n"
