defmodule Main do
  def main do
    IO.gets("")
    |> String.trim()
    |> String.split()
    |> Enum.map(&String.to_integer/1)
    |> process(1)
    |> IO.inspect()
  end
  
  defp process([1, k], acc), do: acc * k
  defp process([n, k], acc), do: process([n - 1, k], acc * (k - 1))
end