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.
[{"code": "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.16, "memory": 14048.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nprint((k*pow(k-1, n-1)))\n", "passed": true, "time": 0.15, "memory": 14296.0, "status": "done"}, {"code": "N,K = map(int,input().split())\nP = K\nfor i in range(N-1):\n  P *= K-1\nprint(P)", "passed": true, "time": 1.94, "memory": 14216.0, "status": "done"}, {"code": "N, K=map(int, input().split(\" \"))\n\nprint(K*(K-1)**(N-1))", "passed": true, "time": 1.95, "memory": 14164.0, "status": "done"}, {"code": "N, K = map(int, input().split())\n\nans = K * (K - 1)**(N - 1)\nprint(ans)", "passed": true, "time": 0.15, "memory": 14048.0, "status": "done"}, {"code": "N, K = map(int, input().split())\n\nres = 1\n\nfor i in range(N):\n    if i == 0:\n        res *= K\n    else:\n        res *= (K-1)\n\nprint(res)", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "N,K=list(map(int,input().split()))\nans = K\nfor i in range(N-1):\n  ans *= (K-1)\nprint(ans)\n", "passed": true, "time": 0.41, "memory": 14240.0, "status": "done"}, {"code": "N, K = map(int,input().split())\nnum = K;\n\nif N != 1 :\n  for i in range(1,N):\n    num *= K-1\n\nprint(num)", "passed": true, "time": 0.16, "memory": 14224.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nprint(K * pow(K-1,N-1))", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "n, k = map(int, input().split())\n\nprint(k * ((k - 1) ** (n - 1)))", "passed": true, "time": 0.17, "memory": 14164.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nprint(K * ((K - 1) ** (N - 1)))", "passed": true, "time": 0.18, "memory": 14280.0, "status": "done"}, {"code": "N,K=map(int,input().split())\nprint(K*((K-1)**(N-1)))", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\n\nprint((k * (k-1)**(n-1)))\n", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nans = k * pow(k-1, n-1)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nans = k\nfor _ in range(n-1):\n    ans *= k-1\nprint(ans)", "passed": true, "time": 0.22, "memory": 14048.0, "status": "done"}, {"code": "N,K = map(int, input().split())\npattern = K*(K-1)**(N-1)\nprint(pattern)", "passed": true, "time": 0.15, "memory": 14296.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nans = k\nfor i in range(n-1):\n        ans = ans * (k -1)\n\nprint(ans)", "passed": true, "time": 0.15, "memory": 14208.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nprint(k*((k-1)**(n-1)))", "passed": true, "time": 0.18, "memory": 14264.0, "status": "done"}, {"code": "n,k = map(int, input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.17, "memory": 14180.0, "status": "done"}, {"code": "N,K = map(int,input().split())\n\nans = K*(K-1)**(N-1)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "lst = input().split()\n\nN = int(lst[0])\nK = int(lst[1])\n\nprint(K * ((K-1) ** (N-1)))", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nprint(k*((k-1)**(n-1)))", "passed": true, "time": 0.17, "memory": 14280.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nprint(k*((k-1)**(n-1)))", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "N,K = map(int,input().split())\n\ndef calculate(n, k):\n    print(k * pow(k-1,n-1))\n\ncalculate(N, K)", "passed": true, "time": 0.23, "memory": 14320.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nprint(k*((k-1)**(n-1)))", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nprint((k * (k-1) ** (n-1)))\n", "passed": true, "time": 0.24, "memory": 14068.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nif n==1:\n  print(k)\nelse:\n  print(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\n\nans = 0\nans += k * (k - 1) ** (n - 1)\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14372.0, "status": "done"}, {"code": "a,b=input().split()\na=int(a)\nb=int(b)\nprint(b*(b-1)**(a-1))", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "a = list(map(int ,input().split()))\nsum = 0\nfor i in range(a[0]):\n    if i == 0:\n        sum = a[1]\n    else:\n        sum *= a[1]-1\n\nprint(sum)", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nx = K*(K-1)**(N-1)\nprint(x)", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "N, K = map(int, input().split())\ntotal = K\nfor i in range(N-1):\n    total *= (K-1)\nprint(total)", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nans = k\nfor i in range(n-1):\n  ans *= k-1\nprint(ans)", "passed": true, "time": 1.82, "memory": 14224.0, "status": "done"}, {"code": "n,k = map(int,input().split())\n\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14176.0, "status": "done"}, {"code": "N, K = map(int,input().split())\nprint(K * (K - 1)**(N - 1))", "passed": true, "time": 0.35, "memory": 14172.0, "status": "done"}, {"code": "n,k=map(int, input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14088.0, "status": "done"}, {"code": "N, K  = [int(x) for x in input().split()]\nans = (K-1)**(N-1)*K\nprint(ans)", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "nk = input().split()\n\nn = int(nk[0])\nk = int(nk[1])\n\np = k * (k-1)**(n-1)\n\nprint(p)\n", "passed": true, "time": 0.15, "memory": 14272.0, "status": "done"}, {"code": "n, k = map(int, input().split())\n\nprint(k * (k - 1) ** (n - 1))", "passed": true, "time": 0.15, "memory": 14184.0, "status": "done"}, {"code": "N, K = map(int, input().split())\n\ncnt = K\nfor i in range(N - 1):\n    cnt *= (K - 1)\nprint(cnt)", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "N, K = list(map(int, input().split()))\n\nprint((K * pow(K-1, N-1)))\n", "passed": true, "time": 0.14, "memory": 14264.0, "status": "done"}, {"code": "N, K = map(int,input().split())\n\nans = K * ((K-1)**(N-1))\nprint(ans)", "passed": true, "time": 0.15, "memory": 14232.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nans = k\nfor i in range(n-1):\n    ans *= k-1\nprint(ans)", "passed": true, "time": 0.15, "memory": 14300.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.15, "memory": 14080.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\nprint((k*((k-1)**(n-1))))\n", "passed": true, "time": 0.15, "memory": 14168.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\n\nans = k * (k-1)**(n-1)\nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14044.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nprint(k * pow(k - 1, n - 1))", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "a,b=map(int,input().split());print(b*(b-1)**(a-1))", "passed": true, "time": 0.14, "memory": 14048.0, "status": "done"}, {"code": "\ndef resolve():\n    n, k = list(map(int, input().split()))\n\n    print((k * (k-1) ** (n-1)))\n\ndef __starting_point():\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14148.0, "status": "done"}, {"code": "N,K = map(int,input().split())\n\nprint(K * (K - 1) ** (N - 1))", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,k = list(map(int,input().split()))\nprint((k*((k-1)**(n-1))))\n", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nprint(k* ((k-1)**(n-1)))", "passed": true, "time": 0.14, "memory": 14156.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14208.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14048.0, "status": "done"}, {"code": "n, k = map(int, input().split())\n\nans = k * pow(k - 1, n-1)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "a,b=map(int,input().split())\nprint(b*(b-1)**(a-1))", "passed": true, "time": 0.14, "memory": 14084.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nans = K * ((K-1) ** (N-1))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "N,K = list(map(int,input().split()))\nprint((K * (K-1)**(N-1)))\n", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.23, "memory": 14088.0, "status": "done"}, {"code": "N, K = list(map(int,input().split()))\nans = 1\n\nans = K * (K - 1) ** (N - 1)\n\nprint(ans)\n    \n", "passed": true, "time": 0.95, "memory": 14128.0, "status": "done"}, {"code": "N,K = map(int, input().split())\n\npr = K\nfor _ in range(1,N):\n  pr *= K-1\nprint(pr)", "passed": true, "time": 0.21, "memory": 14204.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\nif(n!=1 and n!=1 ):\n    print((k*(k-1)**(n-1)))\nif(n == 1):\n    print(k)\n", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "n,k=map(int,input().split())\na=k*(k-1)**(n-1)\nprint(a)", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "n,k = list(map(int,input().split()))\nprint((k*((k-1)**(n-1))))\n", "passed": true, "time": 0.15, "memory": 14204.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nif n == 1:\n    print(k)\n    return\nsu = k\nfor i in range(n-1):\n    su *= (k-1)\nprint(su)", "passed": true, "time": 0.14, "memory": 14076.0, "status": "done"}, {"code": "N, K = list(map(int, input().split()))\nprint((K * pow(K - 1, N - 1)))\n", "passed": true, "time": 0.14, "memory": 14316.0, "status": "done"}, {"code": "MOD = 10**11\n\ndef fast_pow(x, n, MOD):\n    res = 1\n    while n:\n        if n & 1:\n            res = res * x % MOD\n        x = x * x % MOD\n        n >>= 1\n    return res\n\n\nn, k = map(int,input().split())\nif n == 1:\n    print(k)\nelse:\n    print(k * fast_pow(k-1, n-1, MOD))", "passed": true, "time": 0.21, "memory": 14116.0, "status": "done"}, {"code": "n,k=list(map(int,input().split()))\nprint((k*(k-1)**(n-1)))\n", "passed": true, "time": 0.14, "memory": 14232.0, "status": "done"}, {"code": "a,b = map(int,input().split())\n\nprint((b-1)**(a-1)*b)", "passed": true, "time": 0.24, "memory": 14052.0, "status": "done"}, {"code": "N,K=map(int,input().split())\nprint(K*(K-1)**(N-1))", "passed": true, "time": 0.15, "memory": 14052.0, "status": "done"}, {"code": "N, K = map(int, input().split())\n\nprint(K*((K-1)**(N-1)))", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nprint(k*((k-1)**(n-1)))", "passed": true, "time": 0.15, "memory": 14304.0, "status": "done"}, {"code": "\n# ABC046\nN, K = map(int, input().split())\nprint(K*(K-1)**(N-1))", "passed": true, "time": 0.24, "memory": 14184.0, "status": "done"}, {"code": "a,b = map(int,input().split())\nprint(b*(b-1)**(a-1))", "passed": true, "time": 0.24, "memory": 14196.0, "status": "done"}, {"code": "n, k = tuple([int(x) for x in input().split(\" \")])\n\nprint((k * pow(k - 1, n - 1)))\n", "passed": true, "time": 0.23, "memory": 14016.0, "status": "done"}, {"code": "N, K = list(map(int, input().split()))\nans = K\nfor i in range(N - 1):\n  ans *= K - 1\n  \nprint(ans)  \n\n\n", "passed": true, "time": 0.14, "memory": 14284.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "str_line = input().split(\" \")\nnum = int(str_line[0])\nkind = int(str_line[1])\nans = kind \n\nfor i in range(num-1):\n    ans *=(kind - 1)\n    \nprint(ans)", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "n,k = map(int,input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\ndef main():\n    N, K = [int(x) for x in input().split()]\n\n    print((K * (K - 1) ** (N - 1)))\n\n    \n\ndef __starting_point():\n    main()\n\n\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14304.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nm=1\nif n==1:\n    print(k)\nelse:\n    m *= k\n    for i in range(n-1):\n        m *= (k-1)\n    print(m)", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\nN,K = map(int, input().split())\n\nans = K * ((K-1) ** (N-1)) \n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,k = [int(x) for x in input().split()]\nres = k\nfor i in range(1,n):\n  res *= k - 1\nprint(res)", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "def si(): return input()\ndef ii(): return int(input())\ndef fi(): return float(input())\ndef lint(): return list(map(int, input().split()))\ndef lint_dec(): return list([int(x) - 1 for x in input().split()])\ndef lnstr(n): return [input() for _ in range(n)]\ndef lnint(n): return [int(input()) for _ in range(n)]\ndef graph_input(G, m):\n    for _ in range(m):\n        a, b = lint_dec()\n        G[a].append(b)\n        G[b].append(a)\n\n\n\n############################################################\nN, K = lint()\nprint((K * pow(K - 1, N - 1)))\n", "passed": true, "time": 0.14, "memory": 14108.0, "status": "done"}, {"code": "def answer(n: int, k: int) -> int:\n    return k * (k - 1) ** (n - 1)\n\n\ndef main():\n    n, k = map(int, input().split())\n    print(answer(n, k))\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14184.0, "status": "done"}, {"code": "N, K = map(int, input().split(' '))\n\nanswer = (K-1)**(N-1) * K\nprint(answer)", "passed": true, "time": 0.42, "memory": 14044.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "n,k = map(int, input().split())\nans=k*((k-1)**(n-1))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14240.0, "status": "done"}, {"code": "N, K = list(map(int, input().split()))\n\nprint((K * (K - 1) ** (N - 1)))\n", "passed": true, "time": 0.22, "memory": 14220.0, "status": "done"}, {"code": "n,k = list(map(int, input().split()))\np=k\nfor i in range(n-1):\n  p *= k-1\nprint(p)\n", "passed": true, "time": 0.14, "memory": 14112.0, "status": "done"}, {"code": "N, K = [int(x) for x in input().split()]\nprint(K*(K-1)**(N-1))", "passed": true, "time": 0.14, "memory": 14044.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nprint(K * ((K - 1) **(N - 1)))", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "n, k = list(map(int, input().split()))\nprint((k * pow((k-1), (n-1))))\n", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "N,K = list(map(int,input().split()))\n\nprint((K*(K-1)**(N-1)))\n", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "n,k=map(int,input().split())\nans = k*(k-1)**(n-1)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "N,K=map(int,input().split())\n\ns=K*(K-1)**(N-1)\n\nprint(int(s))", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "N, K = map(int, input().split())\nprint(K*(K-1)**(N-1))", "passed": true, "time": 0.14, "memory": 14244.0, "status": "done"}, {"code": "N, K =map(int, input().split())\nprint(K*((K-1)**(N-1)))", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "n, k = map(int, input().split())\nprint(k*(k-1)**(n-1))", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "import re\nimport copy\n\ndef accept_input():\n    N,K = list(map(int,input().split()))\n    return N,K\n\nN,K = accept_input()\n\n\nif K == 1:\n    print(N)\nelse:\n    print((K*((K-1)**(N-1))))\n", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}]