import sys

sys.setrecursionlimit(2147483647)

INF=float("inf")

MOD=10**9+7

input=lambda :sys.stdin.readline().rstrip()

def resolve():

    n,k=list(map(int,input().split()))

    print((k*((k-1)**(n-1))))

resolve()
import sys

INF = 1 << 60

MOD = 10**9 + 7 # 998244353

sys.setrecursionlimit(2147483647)

input = lambda:sys.stdin.readline().rstrip()

def resolve():

    n, k = list(map(int, input().split()))

    print((k * pow(k - 1, n - 1)))

resolve()
import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 10**9 + 7
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n, k = list(map(int, input().split()))
    print((k * ((k - 1) ** (n - 1))))


resolve()

import sys

INF = 1 << 60
MOD = 10**9 + 7  # 998244353
sys.setrecursionlimit(2147483647)
input = lambda: sys.stdin.readline().rstrip()


def resolve():
    n, k = list(map(int, input().split()))
    print((k * pow(k - 1, n - 1)))


resolve()

+INF = 1 << 60 +MOD = 10**9 + 7  # 998244353 -INF = float("inf") -MOD = 10**9 + 7 -    print((k * ((k - 1) ** (n - 1)))) +    print((k * pow(k - 1, n - 1)))