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.

Examples

Input

2 2


Output

2


Input

1 10


Output

10
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
template <class T>
T factorial(T num) {
  if (num == 0 || num == 1) {
    return 1;
  } else {
    return num * factorial(num - 1);
  }
}
template <class T>
T nCr(T n, T r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long balls, colors;
  cin >> balls >> colors;
  if (balls == colors) {
    cout << factorial(balls) << "\n";
  } else if (balls == 1) {
    cout << colors << "\n";
  } else if (balls == 2) {
    long long col_pattern = nCr(colors, (long long)2);
    cout << col_pattern * 2 << "\n";
  } else if (colors == 2) {
    cout << 2 << "\n";
  } else if (balls <= colors) {
    long long pattern = nCr(colors, balls);
    long long row = factorial(balls);
    cout << pattern * row << "\n";
  } else {
    long long res, pattern;
    res = colors * (long long)pow(colors - 1, balls - 1);
    cout << res << "\n";
  }
  return 0;
}
