Problem:
 Score : 200 points    Problem Statement 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 1 2 2      Sample Output 1 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 .       Sample Input 2 1 10      Sample Output 2 10  Since there is only one ball, we can use any of the ten colors to paint it. Thus, the answer is ten.

Solution (Python):
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)

Solution (Python):
N, K = map(int,input().split())

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

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

Solution (Python):
nk = input().split()

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

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

print(p)

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

Solution (Python):
n, k = map(int, input().split())

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

print(ans)

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
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))


if __name__ == '__main__':
    main()

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n,k = I()

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

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
N,K=map(int,input().split())

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

print(int(s))

Solution (Python):
N,K = map(int,input().split())

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

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

Solution (Python):
n,k=map(int,input().split())

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

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

Solution (Python):
def solve():
    N, K = [int(i) for i in input().split()]
    print(K * (K - 1) ** (N - 1))

if __name__ == "__main__":
    solve()

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

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

Solution (Python):


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

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

print(ans)

Solution (Python):

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

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

if __name__ == "__main__":
    resolve()

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

Solution (Python):
n, k = map(int, input().split())

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

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

Solution (Python):
N,K = map(int,input().split())

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

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

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

Solution (Python):
lst = input().split()

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

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

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

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

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

Solution (Python):
N,K = map(int,input().split())

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

calculate(N, K)

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

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

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

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
import sys
input = sys.stdin.readline

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

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

Solution (Python):
n, k = map(int, input().split())

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

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

Solution (Python):
import re
import copy

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

N,K = accept_input()


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

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

Solution (Python):
def resolve():
    import sys
    input = sys.stdin.readline

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

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


if __name__ == "__main__":
    resolve()

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

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

print(num)

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

Solution (Python):
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))

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

Solution (Python):

import sys


def solve(N: int, K: int):
    print(((K-1) ** (N -1)) * K)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    K = int(next(tokens))  
    solve(N, K)

if __name__ == '__main__':
    main()

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

print(ans)

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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

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

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

if __name__ == '__main__':
    main()

Solution (Python):
N, K = map(int, input().split())

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

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

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

Solution (Python):
N, K = map(int, input().split())

res = 1

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

print(res)

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

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

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

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

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

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

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

Solution (Python):
N,K = map(int,input().split())

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

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

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, K = map(int, readline().split())
    ans = K

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

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
N, K = map(int, input().split())

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

print(ans)

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

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

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

Solution (Python):
n, k = map(int, input().split())

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

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

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

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

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

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

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

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

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

Solution (Python):


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

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

Solution (Python):
N, K = map(int,input().split())
ans = 1

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

print(ans)

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

Solution (Python):
n, k = map(int, input().split())

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline

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

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

    

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
N, K = map(int, input().split())

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

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

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

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

Solution (Python):
n,k = map(int, raw_input().split())
print k * ((k-1) ** (n-1))

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

Solution (Python):
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)

Solution (Python):
n,k = map(int,input().split())

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

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

Solution (Python):
n,k = map(int,input().split())

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

Solution (Python):
import math
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


N,K = LI()

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

Solution (Python):
N, K = map(int, input().split())
a=K*(K-1)**(N-1)
print(a)

Solution (Python):
N,K = map(int, input().split())

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

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

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

Solution (Python):

from itertools import product

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

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

Solution (Python):
n, k = map(int, input().split())

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

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

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n,k = m()

ans = 1

for i in range(n):
    if i == 0:
        ans *= k
    else:
        ans *= k-1
print(ans)

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

Solution (Python):
N,K = (int(T) for T in input().split())
print(K*((K-1)**(N-1)))

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

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

Solution (Python):
n,k = list(map(int, input("").split()))
out=k*(k-1)**(n-1)
print(out)

Solution (Python):

a, b = list(map(int, input().split(' ')))
ans = b * pow(b-1, a-1)
print(ans)

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

Solution (Python):
def main():
    N, K = map(int, input().split())

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


if __name__ == "__main__":
    main()

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

Solution (Python):
N, K = map(int,input().split())
ans = 1
for i in range(N):
    if i == 0:
        ans *= K
    else:
        ans *= K-1
print(ans)

Solution (Python):




import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 2"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 10"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """10 8"""
        output = """322828856"""
        self.assertIO(input, output)


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


if __name__ == "__main__":
    
	resolve()

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

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

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

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

Solution (Python):
N, K = map(int, input().split())

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

print(ans)

Solution (Python):
def main():
    N,K = map(int,input().split())
    if N == 1:
        print(str(K))
    else:
        ans = (K-1)**(N-1)*K
        print(str(ans))





if __name__ == '__main__':
    main()

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N, K = LI()

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

    print(ans)

if __name__ == '__main__':
    resolve()

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

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

Solution (Python):
N, K = map(int, input().split())
ans = 0

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

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

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

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

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

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

Solution (Python):
n,k  = map(int, input().split())

if n == 1:
  number = k
else:
  number = k*(k-1)**(n-1)

print(number)

Solution (Python):
n,k=map(int,input().split())

numk=k
for _ in range(2,n+1):
    numk=numk*(k-1)
print(numk)

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):

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

    for i in range(n):
        if i == 0:
            val = k
        else:
            val *= (k-1)
    else:
        print(val)


if __name__ ==  "__main__":
    main()

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

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

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

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

Solution (Python):
N,K=map(int,input().split())

ans=1
for i in range(N):
  if i==0:
    ans *= K
    continue
  ans *= K-1
  
print(ans)

Solution (Python):
sample = input() 
new_sample = sample.split(" ")

ball = int(new_sample[0]) 
color = int(new_sample[1]) 
if ball > 1 and color == 1:
  print(0)
else:
  product = color
  for i in range(1, ball):
    product *= (color-1)
  print(product)

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

Solution (Python):
i = input()
j = i.split()
num_balls = int(j[0])
num_colors = int(j[1])
product = num_colors
if(num_balls > 1 and num_colors == 1):
  print(0)
else:
  for i in range(1, num_balls):
    product *= (num_colors - 1)
  print(product)

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

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

Solution (Python):
N, K = list(map(lambda n: int(n), input().split(" ")))

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

Solution (Python):
N, K = list(map(lambda n: int(n), input().split(" ")))

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

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

Solution (Python):
a,b =map(int,input().split())
print(b*((b-1)**(a-1)) if a>1 else b)

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):
n, k = map(int, input().split())
if n == 1:
  print(k)
else:
  ans = k
  for _ in range(2, n + 1):
    ans *= (k - 1)
  print(ans)

Solution (Python):
n,k=map(int,input().split())

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

Solution (Python):
N, K = map(int, input().split())

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

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

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
n,k = map(int,input().split())

var = k

for i in range(n-1):
    var *= k-1

print(var)

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

Solution (Python):
N, K = map(int, input().split())

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

Solution (Python):
N,K = map(int, input().split())
cnt = K*(K-1)**(N-1)
print(cnt)

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

Solution (Python):
N,K = map(int,input().split())

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

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

Solution (Python):







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

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

print(ans)

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

Solution (Python):
n, k = map(int, input().split())

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

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

Solution (Python):
def resolve():
    N, M = map(int, input().split())
    print(M*(M-1)**(N-1))
resolve()

Solution (Python):
N, K = map(int, input().split())
ans = 1

for n in range(N):
  if n == 0:
    ans *= K
  else:
    ans *= K-1
  
print(ans)

Solution (Python):
s = input()
s = s.split()
n = int(s[0])
k = int(s[1])

if n==1:
  print(k)
elif n==2:
  print(k*(k-1))
else:
  ans = k
  for i in range(n-1):
    ans = ans*(k-1)
  print(ans)

Solution (Python):


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

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

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

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

Solution (Python):
n, k = map(int, input().split())

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

Solution (Python):
N,K = map(int,input().split())

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

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

Solution (Python):
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

    
def solve():
    n,k=mp()
    pr(k*(k-1)**(n-1))
for _ in range(1):
    solve()

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

Solution (Python):
N,K=map(int,input().split())
ans=1
for i in range(N):
  if i==0:
    ans*=K
  else:
    ans*=K-1
else:
  print(ans)

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

Solution (Python):



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

ans=K

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

print(ans)

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

Solution (Python):
def main():
    n,k=map(int,input().split())
    x=k-1
    for i in range(1,n):
        k*=x
    print(k)
    
main()

Solution (Python):
from math import pow

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

Solution (Python):
N,K = map(int, input().split())

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

Solution (Python):
n,k=map(int,input().split())
a=1
for i in range(n):
  if i == 0:
    a*=k
  else:
    a*=(k-1)

print(a)

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

Solution (Python):
def main():
    n, k = map(int, input().split())
    ans = k * ((k-1)**(n-1))
    print(ans)


if __name__ == "__main__":
    main()

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

Solution (Python):


def main():

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

    for i in range(N):
        if i == 0:
            ans *= K

        else:
            ans *= (K-1)

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N,K = map(int,input().split())
ans = 1
for i in range(N):
  if i == 0:
    ans *= K
  else:
    ans *= K-1
print(ans)

Solution (Python):
N,K=map(int,input().split())

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

print(ans)

Solution (Python):
n, k = map(int, input().split())

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

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

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

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

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

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

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

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

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

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

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n, k = map(int, input().split())
    if n == 1:
        print(k)
        sys.exit()
    r = k
    r *= pow(k - 1, n - 1)
    print(r)

if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split())

ans = 1
for i in range(n):
    ans = ans*k if i == 0 else ans*(k-1)

print(ans)

Solution (Python):
n,k = map(int,input().split())

ans = k

for i in range(n-1):
    ans *= (k - 1)

print(ans)

Solution (Python):
def resolve():
    N, K = list(map(int, input().split()))
    paint_way_count = K*(K-1)**(N-1)
    print(paint_way_count)

resolve()

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K = map(int, readline().split())

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

    return


if __name__ == '__main__':
    main()

Solution (Python):
n, k = map(int, input().split(" "))

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

Solution (Python):

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

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

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

Solution (Python):

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

Solution (Python):
n,c=map(int,input().split())
print(c*(c-1)**(n-1))

Solution (Python):
import sys
N,K = map(int,sys.stdin.readline().rstrip().split())
print(K*(K-1)**(N-1))

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

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

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

Solution (Python):
N,K = map(int,input().split())
print(K*((K-1)**(N-1))**(N>1))

Solution (Python):
LL = input().split()
N = int(LL[0])
K = int(LL[1])
if N ==1 or K ==1:
  ans = N*K
else:
  ans =K*(K-1)**(N-1)
print(ans)

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

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

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

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

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

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

Solution (Python):
n, k = [int(w) for w in input().split()]

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

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

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

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

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

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

Solution (Python):
N, K = map(int, input().split())

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

print(count)

Solution (Python):
n,k = (int(x) for x in input().split())
x = k*((k-1)**(n-1))
print (x)

Solution (Python):
s = input().split()


n = int(s[0])


k = int(s[1])

answer = 1

for num in range(n - 1):
    answer *= k - 1

answer *= k

print(int(answer))

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue

from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()

    ret = 1
    for n in range(N):
        ret *= K
        if n == 0:
            K -= 1

    print(ret)



if __name__ == '__main__':
    main()