n, k = gets.split.map(&:to_i)
p = gets.split.map(&:to_i)
already_sorted = n - k + 1

(n - k + 1).times do |i|
  (k - 1).times do |ii|
    if p[i + ii - 1] > p[i + ii]
      already_sorted -= 1
      break
    end
  end
end

puts n - k + 1 - (already_sorted > 1 ? already_sorted - 1 : 0)
