n,k=gets.split.map(&:to_i)
q = gets.split.map(&:to_i)
c = 1
ff = true
(n-k).times do |i|
  unless q[i] < q[i+1..i+k-1].min && q[i+1..i+k-1].max < q[i+k]
    f = true
    (k-1).times do |j|
      unless q[i+1+j] < q[i+2+j]
        f = false
        break
      end
    end
    if !f
      c += 1
    end
    if ff && f
      ff = false
      c += 1
    end
  end
end
p c
