import scala.annotation.tailrec

object Main extends App {
  val primes: Stream[Long] =
    Stream.cons(2L, Stream.iterate(3L) { _ + 2L } filter { i =>
      (i > 1) && primes.takeWhile(_ <= Math.sqrt(i)).forall(i % _ != 0)
    })

  def primeFactorization(n: Long): List[(Long, Long)] =
    primeFactorization(n, primes)

  def primeFactorization(n: Long, primes: Stream[Long]): List[(Long, Long)] = {
    if (n == 1L) List.empty
    else {
      val (count, vn) = trialDivision(n, primes.head, 0L)
      if (count == 0L) primeFactorization(vn, primes.tail)
      else (primes.head, count) :: primeFactorization(vn, primes.tail)
    }
  }

  @tailrec
  def trialDivision(n: Long, p: Long, e: Long): (Long, Long) = {
    if (n % p != 0) (e, n)
    else trialDivision(n / p, p, e + 1L)
  }

  val Array(n, p) = io.StdIn.readLine.split(" ").map(_.toLong)
  println(primeFactorization(p).foldLeft(1L) { (acc, v) =>
    if (n > v._2) acc
    else acc * math.pow(v._1, v._2 / n).toLong
  })
}
