import Control.Applicative

calc :: Int -> Int -> Int
calc n k
    | n==1 = k
    | otherwise = k*(k-1)^(n-1)

main = do
    [n,k] <- map read.words <$> getLine
    --s <- (map read . words) <$> getLine
    print $ calc n k
