import Control.Monad

solve :: Int -> Int -> Int
solve 1 m = 1
solve n m = m * solve (n-1) m 
main = do
  [n, k] <- map (read::String->Int) . words <$> getLine
  putStrLn $ show (k * (solve n (k - 1)))