n,k = gets.chomp.split(" ").map(&:to_i)
s = gets.chomp.split(" ").map(&:to_i)

ptn = 1
kset = []
kmax = 0
kmin = n-1

s[0...k].each do |e|
  if kmax < e
    kmax = e
  end
  if kmin > e
    kmin = e
  end
  kset << e
end

(n-k).times do |i|
  addptn = false
  j = i+k
  e = s[j]
  pe = kset.shift
  if pe == kmax
    kmax = kset.max
  end
  if pe == kmin
    kmin = kset.min
  else
    addptn = true
  end
  if kmax < e
    kmax = e
  else
    addptn = true
  end
  if kmin > e
    kmin = e
  end
  kset << e
  if addptn
    ptn += 1
  end
end

print("#{ptn}")