n,k = gets.split.map &:to_i
p = gets.split.map &:to_i

max = n - k + 1

if n == k then
	puts 1
	exit
end

p.each_cons(k + 1).with_index { |w, i|
	w_t = w[1..-2]
	if w[0] < w_t.min && w[-1] > w_t.max then
		max -= 1
	end
}

p_count = 0
count = 1
t_p = p[0]

p[1..-1].each{ |px|
	if px > t_p then
		count += 1
	else
		if count >= k then
			p_count += 1
		end
		count = 1
	end

	t_p = px
}

puts max - p_count