import re

import doctest





class IO_for_Contest(object):

    @staticmethod

    def my_input():

        # return raw_input()

        return eval(input())



    @staticmethod

    def read_from_input():

        return IO_for_Contest.read_n_int(2)



    @staticmethod

    def read_line():

        return IO_for_Contest.my_input().strip()



    @staticmethod

    def read_int():

        return int(IO_for_Contest.my_input().strip())



    @staticmethod

    def read_n_int(n):

        return list(map(

                    int,

                    re.split('\s+', IO_for_Contest.my_input().strip())))[: n]





def solve():

    buf = IO_for_Contest.read_from_input()

    n = buf[0]

    k = buf[1]

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





if __name__ == '__main__':

    # doctest.testmod()

    solve()
def solve():

    n, k = read()

    result = think(n, k)

    write(result)





def read():

    return read_int(2)





def read_int(n):

    return list([int(x) for x in read_line().split(' ')])[:n]





def read_line(n=0):

    if n == 0:

        return input().rstrip()

    else:

        return input().rstrip()[:n]





def think(n, k):

    return k * (k - 1) ** (n - 1)





def write(result):

    print(result)





if __name__ == '__main__':

    solve()
import re
import doctest


class IO_for_Contest(object):
    @staticmethod
    def my_input():
        # return raw_input()
        return eval(input())

    @staticmethod
    def read_from_input():
        return IO_for_Contest.read_n_int(2)

    @staticmethod
    def read_line():
        return IO_for_Contest.my_input().strip()

    @staticmethod
    def read_int():
        return int(IO_for_Contest.my_input().strip())

    @staticmethod
    def read_n_int(n):
        return list(map(int, re.split("\s+", IO_for_Contest.my_input().strip())))[:n]


def solve():
    buf = IO_for_Contest.read_from_input()
    n = buf[0]
    k = buf[1]
    print((k * ((k - 1) ** (n - 1))))


if __name__ == "__main__":
    # doctest.testmod()
    solve()

def solve():
    n, k = read()
    result = think(n, k)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list([int(x) for x in read_line().split(" ")])[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, k):
    return k * (k - 1) ** (n - 1)


def write(result):
    print(result)


if __name__ == "__main__":
    solve()

-import re -import doctest +def solve(): +    n, k = read() +    result = think(n, k) +    write(result) -class IO_for_Contest(object): -    @staticmethod -    def my_input(): -        # return raw_input() -        return eval(input()) - -    @staticmethod -    def read_from_input(): -        return IO_for_Contest.read_n_int(2) - -    @staticmethod -    def read_line(): -        return IO_for_Contest.my_input().strip() - -    @staticmethod -    def read_int(): -        return int(IO_for_Contest.my_input().strip()) - -    @staticmethod -    def read_n_int(n): -        return list(map(int, re.split("\s+", IO_for_Contest.my_input().strip())))[:n] +def read(): +    return read_int(2) -def solve(): -    buf = IO_for_Contest.read_from_input() -    n = buf[0] -    k = buf[1] -    print((k * ((k - 1) ** (n - 1)))) +def read_int(n): +    return list([int(x) for x in read_line().split(" ")])[:n] + + +def read_line(n=0): +    if n == 0: +        return input().rstrip() +    else: +        return input().rstrip()[:n] + + +def think(n, k): +    return k * (k - 1) ** (n - 1) + + +def write(result): +    print(result) -    # doctest.testmod()