primes :: [Int]
primes = sieve (2 : [3, 5..])
  where
    sieve (p:xs) = p : sieve [ x | x <- xs, x `mod` p > 0]

eff_prime::Int->Int->[Int]
eff_prime n p = takeWhile (large n p) primes

eater::Int->Int->[Int]->Int
eater n p []    = 1
eater n p (pr:prs)= let (p',k) = (multi_div p pr) in (pr^(div k n))*(eater n p' prs)

large::Int->Int->Int->Bool
large n p pr =  n <= (loga pr p)


loga::Int->Int->Int
loga k l = if k > l then 0 else 1 + (loga k (div l k))

multi_div::Int->Int->(Int,Int)
multi_div n divider = if mod n divider /= 0
                        then (n,0)
                        else let (q,i) = multi_div (div n divider) divider in (q,i+1)

solver::Int->Int->Int
solver n p  = eater n p (eff_prime n p)

main::IO()
main=do
  d<-getLine
  let n:p:[]=map read (words d)
  print (solver n p)
