import io.StdIn.{readInt, readLine}
object Main extends App {
  val Array(n,k) = readLine.split(" ").map(_.toInt)

  // general expression
  // k*(k-1)^(n-1)

  val factor1 = BigInt(k)
  val factor2 = BigInt(k-1).pow(n-1)
  println(factor1*factor2)
  
}