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

sum = 1
b = n - 1
a = n - k
while a > 0
  unless ps[a-1] < ps[a] && ps[b-1] < ps[b]
    sum += 1
  end
  a -= 1
  b -= 1
end
puts sum