let (n, p) = Scanf.sscanf (read_line ()) "%d %d" @@ fun n p -> (n, p)

let rec prime_fact acc i n =
  if n = 0 then acc
  else if n < i * i then n :: acc
  else if n mod i = 0 then prime_fact (i :: acc) i (n / i)
  else prime_fact acc (i + 1) n

let prime_fact n =
  List.fold_left (fun acc i ->
    match acc with
      | [] -> [(i, 1)]
      | (v, cnt) :: xs -> if v = i then (v, cnt + 1) :: xs else (i, 1) :: (v, cnt) :: xs
  ) [] @@ prime_fact [] 2 n

let ps = prime_fact p

let rec pow n = function
  | 0 -> 1
  | i -> n * pow n (i - 1)


let () = 
  let ans = List.fold_left (fun ans (v, cnt) ->
    ans * (pow v (cnt / n))
  ) 1 ps in
  Printf.printf "%d\n" ans