There are N balls placed in a row. AtCoDeer the deer is painting each of these in one of the K colors of his paint cans. For aesthetic reasons, any two adjacent balls must be painted in different colors.  Find the number of the possible ways to paint the balls.
N, K = map(int, input().split())

ans = K
for i in range(N-1):
    ans += (K-1)

print(ans)
N, K = map(int, input().split())

ans = K
for i in range(N-1):
    ans *= (K-1)

print(ans)