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.

-----Constraints-----
 - 1≦N≦1000
 - 2≦K≦1000
 - The correct answer is at most 2^{31}-1.

-----Input-----
The input is given from Standard Input in the following format:
N K

-----Output-----
Print the number of the possible ways to paint the balls.

-----Sample Input-----
2 2

-----Sample Output-----
2

We will denote the colors by 0 and 1. There are two possible ways: we can either paint the left ball in color 0 and the right ball in color 1, or paint the left in color 1 and the right in color 0.

Difficulty: introductory

Starter code:

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

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


N,K = map(int,input().split())
P = K
for i in range(N-1):
  P *= K-1
print(P)

N, K=map(int, input().split(" "))

print(K*(K-1)**(N-1))

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

ans = K * (K - 1)**(N - 1)
print(ans)

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

res = 1

for i in range(N):
    if i == 0:
        res *= K
    else:
        res *= (K-1)

print(res)

N,K=list(map(int,input().split()))
ans = K
for i in range(N-1):
  ans *= (K-1)
print(ans)


N, K = map(int,input().split())
num = K;

if N != 1 :
  for i in range(1,N):
    num *= K-1

print(num)

N, K = map(int, input().split())
print(K * pow(K-1,N-1))

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

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

N, K = map(int, input().split())
print(K * ((K - 1) ** (N - 1)))

N,K=map(int,input().split())
print(K*((K-1)**(N-1)))

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

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


n, k = map(int, input().split())
ans = k * pow(k-1, n-1)
print(ans)

n, k = map(int, input().split())
ans = k
for _ in range(n-1):
    ans *= k-1
print(ans)

N,K = map(int, input().split())
pattern = K*(K-1)**(N-1)
print(pattern)

n, k = map(int, input().split())
ans = k
for i in range(n-1):
        ans = ans * (k -1)

print(ans)

n,k = map(int,input().split())
print(k*((k-1)**(n-1)))

n,k = map(int, input().split())
print(k*(k-1)**(n-1))

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

ans = K*(K-1)**(N-1)
print(ans)

lst = input().split()

N = int(lst[0])
K = int(lst[1])

print(K * ((K-1) ** (N-1)))

n,k=map(int,input().split())
print(k*((k-1)**(n-1)))

n, k = map(int, input().split())
print(k*((k-1)**(n-1)))

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

def calculate(n, k):
    print(k * pow(k-1,n-1))

calculate(N, K)

n,k = map(int,input().split())
print(k*((k-1)**(n-1)))

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


n,k=map(int,input().split())
if n==1:
  print(k)
else:
  print(k*(k-1)**(n-1))

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

ans = 0
ans += k * (k - 1) ** (n - 1)
print(ans)


a,b=input().split()
a=int(a)
b=int(b)
print(b*(b-1)**(a-1))

a = list(map(int ,input().split()))
sum = 0
for i in range(a[0]):
    if i == 0:
        sum = a[1]
    else:
        sum *= a[1]-1

print(sum)

N, K = map(int, input().split())
x = K*(K-1)**(N-1)
print(x)

N, K = map(int, input().split())
total = K
for i in range(N-1):
    total *= (K-1)
print(total)

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())

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

N, K = map(int,input().split())
print(K * (K - 1)**(N - 1))

n,k=map(int, input().split())
print(k*(k-1)**(n-1))

N, K  = [int(x) for x in input().split()]
ans = (K-1)**(N-1)*K
print(ans)

nk = input().split()

n = int(nk[0])
k = int(nk[1])

p = k * (k-1)**(n-1)

print(p)


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

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

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

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

N, K = list(map(int, input().split()))

print((K * pow(K-1, N-1)))


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

ans = K * ((K-1)**(N-1))
print(ans)

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())
print(k*(k-1)**(n-1))

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


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

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


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

a,b=map(int,input().split());print(b*(b-1)**(a-1))


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

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

def __starting_point():
    resolve()

__starting_point()

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

print(K * (K - 1) ** (N - 1))

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


n,k = map(int,input().split())
print(k* ((k-1)**(n-1)))

n,k=map(int,input().split())
print(k*(k-1)**(n-1))

n,k=map(int,input().split())
print(k*(k-1)**(n-1))

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

ans = k * pow(k - 1, n-1)

print(ans)

a,b=map(int,input().split())
print(b*(b-1)**(a-1))

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

N,K = list(map(int,input().split()))
print((K * (K-1)**(N-1)))


n,k = map(int,input().split())
print(k*(k-1)**(n-1))

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

ans = K * (K - 1) ** (N - 1)

print(ans)
    


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

pr = K
for _ in range(1,N):
  pr *= K-1
print(pr)

n,k=list(map(int,input().split()))
if(n!=1 and n!=1 ):
    print((k*(k-1)**(n-1)))
if(n == 1):
    print(k)


n,k=map(int,input().split())
a=k*(k-1)**(n-1)
print(a)

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


n,k = map(int,input().split())
if n == 1:
    print(k)
    return
su = k
for i in range(n-1):
    su *= (k-1)
print(su)

N, K = list(map(int, input().split()))
print((K * pow(K - 1, N - 1)))


MOD = 10**11

def fast_pow(x, n, MOD):
    res = 1
    while n:
        if n & 1:
            res = res * x % MOD
        x = x * x % MOD
        n >>= 1
    return res


n, k = map(int,input().split())
if n == 1:
    print(k)
else:
    print(k * fast_pow(k-1, n-1, MOD))

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


a,b = map(int,input().split())

print((b-1)**(a-1)*b)

N,K=map(int,input().split())
print(K*(K-1)**(N-1))

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

print(K*((K-1)**(N-1)))

n,k = map(int,input().split())
print(k*((k-1)**(n-1)))


# ABC046
N, K = map(int, input().split())
print(K*(K-1)**(N-1))

a,b = map(int,input().split())
print(b*(b-1)**(a-1))

n, k = tuple([int(x) for x in input().split(" ")])

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


N, K = list(map(int, input().split()))
ans = K
for i in range(N - 1):
  ans *= K - 1
  
print(ans)  




n, k = map(int, input().split())
print(k*(k-1)**(n-1))

str_line = input().split(" ")
num = int(str_line[0])
kind = int(str_line[1])
ans = kind 

for i in range(num-1):
    ans *=(kind - 1)
    
print(ans)

n,k = map(int,input().split())
print(k*(k-1)**(n-1))

import sys
input = sys.stdin.readline

def main():
    N, K = [int(x) for x in input().split()]

    print((K * (K - 1) ** (N - 1)))

    

def __starting_point():
    main()



__starting_point()

n,k=map(int,input().split())
m=1
if n==1:
    print(k)
else:
    m *= k
    for i in range(n-1):
        m *= (k-1)
    print(m)

# -*- coding: utf-8 -*-

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

ans = K * ((K-1) ** (N-1)) 

print(ans)

n,k = [int(x) for x in input().split()]
res = k
for i in range(1,n):
  res *= k - 1
print(res)

def si(): return input()
def ii(): return int(input())
def fi(): return float(input())
def lint(): return list(map(int, input().split()))
def lint_dec(): return list([int(x) - 1 for x in input().split()])
def lnstr(n): return [input() for _ in range(n)]
def lnint(n): return [int(input()) for _ in range(n)]
def graph_input(G, m):
    for _ in range(m):
        a, b = lint_dec()
        G[a].append(b)
        G[b].append(a)



############################################################
N, K = lint()
print((K * pow(K - 1, N - 1)))


def answer(n: int, k: int) -> int:
    return k * (k - 1) ** (n - 1)


def main():
    n, k = map(int, input().split())
    print(answer(n, k))


def __starting_point():
    main()
__starting_point()

N, K = map(int, input().split(' '))

answer = (K-1)**(N-1) * K
print(answer)

n,k=map(int,input().split())
print(k*(k-1)**(n-1))

n,k = map(int, input().split())
ans=k*((k-1)**(n-1))
print(ans)

N, K = list(map(int, input().split()))

print((K * (K - 1) ** (N - 1)))


n,k = list(map(int, input().split()))
p=k
for i in range(n-1):
  p *= k-1
print(p)


N, K = [int(x) for x in input().split()]
print(K*(K-1)**(N-1))

N, K = map(int, input().split())
print(K * ((K - 1) **(N - 1)))

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


N,K = list(map(int,input().split()))

print((K*(K-1)**(N-1)))


n,k=map(int,input().split())
ans = k*(k-1)**(n-1)
print(ans)

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

s=K*(K-1)**(N-1)

print(int(s))

N, K = map(int, input().split())
print(K*(K-1)**(N-1))

N, K =map(int, input().split())
print(K*((K-1)**(N-1)))

n, k = map(int, input().split())
print(k*(k-1)**(n-1))

import re
import copy

def accept_input():
    N,K = list(map(int,input().split()))
    return N,K

N,K = accept_input()


if K == 1:
    print(N)
else:
    print((K*((K-1)**(N-1))))