n,k = gets.chomp.split.map(&:to_i)
array_p = gets.split.map!{|i| i.to_i}
results = []

for index in 0..n-k
  insert_array = Marshal.load(Marshal.dump(array_p))
  index_l = k - 1 + index

  array_p_k = array_p[index..index_l]
  sort_array = array_p_k.sort
  insert_array[index..index_l] = sort_array

  results[index] = insert_array
end

result = results.uniq.length
p result
