let rec power ( * ) one m = function
  | 0 -> one
  | n when n mod 2 = 0 ->
      power ( * ) one (m * m) (n / 2)
  | n ->
      m * power ( * ) one m (n - 1)

let () = Printf.printf "%d\n" @@ Scanf.scanf "%d %d" @@ fun n k ->
  power ( * ) 1 (k - 1) (n - 1) * k