import Data.List.Split

toInt :: String -> Int
toInt = read :: String -> Int

main = do
  s <- getLine
  let l = splitOn " " s
  let n = toInt (l!!0)
  let k = toInt (l!!1)
  putStrLn $ show (k*(k-1)^(n-1))
