fun main(args: Array<String>) {

    val inLine = readLine()?.split(" ").orEmpty()
    val countN = inLine[0].toLong()
    val colorK = inLine[1].toLong()


    if(countN == 1L){
        println(colorK)
    }else{
        println( colorK * paintPattern(countN - 1,colorK - 1))
    }

}

fun paintPattern(n: Long, k:Long): Long{
    if(n <= 1) return k
    return k * paintPattern(n - 1, k)

}