# -*- coding utf-8 -*-



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



if n==1:

    print((n*k))

else:

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

# -*- coding utf-8 -*-

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



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

# -*- coding utf-8 -*-
n, k = list(map(int, input().split()))
if n == 1:
    print((n * k))
else:
    print((k * (k - 1) ** (n - 1)))

# -*- coding utf-8 -*-
n, k = list(map(int, input().split()))
print((k * (k - 1) ** (n - 1)))

-if n == 1: -    print((n * k)) -else: -    print((k * (k - 1) ** (n - 1))) +print((k * (k - 1) ** (n - 1)))