let reads f = stdin.ReadLine().Split(' ') |> Array.map f

let split2 left front array =
    array
    |> Array.splitAt left
    |> (fun (l,r) ->
        let (f,r) = Array.splitAt front r
        [|l; f; r|]
    )

let partSort array =
    let [|l; f; r|] = array
    [|l; Array.sort f; r|]
    |> Array.concat

[<EntryPoint>]
let main _ =
    let [|n; k|] = reads int
    let ps = reads int
    [|0..n - k|]
    |> Array.map ((fun x -> split2 x k ps) >> partSort)
    |> Array.distinct
    |> Array.length
    |> printfn "%d"

    0
