import Control.Applicative
import Control.Monad
import Data.List
import Text.Printf

pf m = pfsub m (2:[3,5..])
  where
    pfsub n pl@(p:ps)
      | n == 1 = []
      | r == 0 = p : pfsub q pl
      | q * q < n = [n]
      | otherwise = pfsub n ps
      where
        (q, r) = divMod n p

solve [n, p] = product [head s ^ (length s `div` n)| s <- pfs]
  where
    pfs = group $ pf p

main = map read . words <$> getLine >>= print . solve