require 'set'
n, k = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)

result_set = Set.new

(n - k + 1).times do |i|
  part = p[i, k].sort

  result_set.add(p.map.with_index do |e, idx|
    if (i..(i + k - 1)) === idx
      part[idx - i]
    else
      e
    end
  end)
end

puts result_set.size
