N, K = gets.split.map(&:to_i)
P = gets.split.map(&:to_i)

n = 1
s = P[0,K].sort
(N-K).times {|i|
	pop, push = P[i], P[i+K]
	s.insert(s.bsearch_index{|_| push < _ }||K, push) # K+1 (length)
	min, max = s[0], s[-1]
	s.delete_at(s.bsearch_index{|_| pop <=> _ }) # K (length)
	n += 1 unless pop == min and push == max
}

p n
