N,K=gets.chomp.split(" ").map(&:to_i)
array = gets.chomp.split(" ").map(&:to_i)

sorteds = []
(0..N-K).each_with_index do |e, i|
    sub = array.slice(i..(i+K-1)).sort
    sorted = array.dup
    (0..(K-1)).each do |j|
        sorted[j+i] = sub[j]
    end
    sorteds.push(sorted)
end
unisorteds = sorteds.uniq


puts unisorteds.length
