n,k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split(" ").map(&:to_i)

ptn = 0

h = {}

(n-k+1).times do |i|
  if h[s[0...i]+s[i...i+k].sort_by{|e| e}+s[i+k...n]].nil?
    ptn += 1
  end
  h[s[0...i]+s[i...i+k].sort_by{|e| e}+s[i+k...n]] = 1
end

print("#{ptn}")