n, k = gets.split(' ').map(&:to_i)
ps = gets.split(' ').map(&:to_i)

answer = 1

min, max = ps[0, k].minmax

1.upto(n - k).each do |offset|
  prev_min, prev_max = min, max
  min, max = ps[offset, k].minmax

  if ps[offset - 1] <= prev_min && ps[offset + k - 1] >= prev_max
    next
  end

  answer += 1
end

puts answer
