N, K = gets.chomp.split(" ").map(&:to_i)
A = gets.chomp.split(" ").map(&:to_i)

ans = 0
(1..(K - 1)).each{|k|
  s = A[0, k].inject(:+)
  i = 0
  begin
    ans += 1 if s % K == k
    break if i >= N - k
    s += A[i + k] - A[i]
    i += 1
  end while(true)
}

puts ans
