import algorithm, future, hashes, macros, math, sequtils, sets, strutils, tables, unicode

template readString: string = stdin.readLine
template readStrings: seq[string] = stdin.readLine.split
template readInt: int = stdin.readLine.parseInt
template readInts: seq[int] = stdin.readLine.split.map(parseInt)
template readInt64: int64 = stdin.readLine.parseBiggestInt
template readInt64s: seq[int64] = stdin.readLine.split.map(parseBiggestInt)
template readFloat: float = stdin.readLine.parseFloat
template readFloats: seq[float] = stdin.readLine.split.map(parseFloat)
template times(n: int, body: untyped): untyped = (for _ in 0..<n: body)
proc newSeq2[T](n1, n2: Natural): seq[seq[T]] = newSeqWith(n1, newSeq[T](n2))
proc newSeq3[T](n1, n2, n3: Natural): seq[seq[seq[T]]] = newSeqWith(n1, newSeqWith(n2, newSeq[T](n3)))

macro unpack*(rhs: seq, cnt: static[int]): auto =
  let t = genSym(); result = quote do:(let `t` = `rhs`;())
  for i in 0..<cnt: result[0][1].add(quote do:`t`[`i`])

# --------------------------------------------------- #

var (N, P) = readInts.unpack(2)

var exponent = initTable[int, int]()
proc factorize(N: int) =
  var n = N
  var p = 2
  while p ^ 2 <= n:
    if n mod p == 0:
      n = n div p
      if not exponent.hasKey(p):
        exponent[p] = 1
      else:
        exponent[p] += 1
    else:
      p += 1
  if not exponent.hasKey(n):
    exponent[n] = 1
  else:
    exponent[n] += 1

proc main =
  if N == 1:
    echo P
    quit()
  var res = 1
  factorize(P)
  for key in exponent.keys:
    if exponent[key] div N > 0:
      res *= (exponent[key] div N) * key
  echo res

main()