primeFactorize 1 = []
primeFactorize x =
    let v = head $ nativeFactors x in
        v : primeFactorize (x `div` v)
    where
        nativeFactors n = [a | a <- [2..n], n `mod` a == 0]


count xs = loop xs 1
    where
        loop [] c = []
        loop (x:[]) c = (x, c+1):[]
        loop (x:y:[]) c = if x == y 
                          then (x, c+2):[]
                          else (x, c+1):(y, 1):[]
        loop (x:y:xs) c = if x == y
                          then loop (y:xs) (c+1)
                          else (x, c):loop (y:xs) 1


main = do
    (n:p:_) <- fmap (map read . words) getLine :: IO[Integer]
    print $ solve n p

solve :: Integer -> Integer -> Integer
solve n p =
    let ps = count $ primeFactorize p
    in product . map (\ (x, e) -> x ^ (e `div` n)) $ ps
        