let solve (n:bigint) (k:bigint) =
    let rec solve' idx result =
        if idx >= n then result
        else
            let nextResult = result * (k - bigint 1)
            solve' (idx + bigint 1) nextResult
    solve' (bigint 1) k


let () =
    let n, k = stdin.ReadLine () |>
               (fun line -> line.Split()) |>
               (fun arr -> (int arr.[0], int arr.[1])) |>
               (fun (n, k) -> bigint n, bigint k)

    solve n k |> printfn "%A"