Option Strict On
Imports System.Console
Imports System.Collections.Generic

Module Program

    Sub Main()
        Dim n As Integer = NextInt()
        Dim k As Integer = NextInt()

        Dim ans As Integer = 1

        For i As Integer = 0 To n - 1
            ans *= k - B2i(i <> 0)
        Next

        WriteLine(ans)
    End Sub

    Function B2i(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of String)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return String.Join("", result)
    End Function

End Module
