process.stdin.resume();
process.stdin.setEncoding("utf-8");

process.stdin.on("data", function(chunk){
  var array = chunk.replace("\n", "").split(" ");
  var a = array[0];
  var b = array[1];
  var c = Math.pow(b-1, a-1);
  var result = b * c;
  process.stdout.write(JSON.stringify(result));
})
