main = do
  (n:p:xs) <- (map read) . words <$> getLine
  putStrLn . show $ solve n p


solve :: Integer -> Integer -> Integer
solve n p = calcFactors n p primeList

calcFactors :: Integer -> Integer -> [Integer] -> Integer
calcFactors n 1 primes = 1
calcFactors n prod (pr:primes) =
  let nd = nDiv prod pr
  in if pr * n > prod then 1 else
    (pr ^ (nd `div` n)) * (calcFactors n (prod `div` (pr^nd)) primes)

nDiv x pr = if x `mod` pr == 0 then 1 + (nDiv (x `div` pr) pr) else 0

--primeList :: Integral a => a
primeList = 2 : prime'
prime' = 3 : 5 : 7 : (siege 3 prime')
siege m (a:b:xs) = [n|n<-[a^2,a^2+2..b^2-2],gcd n m<2] ++ (siege (m*b) (b:xs))
