class Array
  def cumsum; s = 0; map{|k| s += k } end
  def mod(m); map{|k|k%m} end
end

n,k = gets.split.map(&:to_i)
a   = gets.split.map{ |k| k.to_i - 1 }

b = a.cumsum.mod(k)
ans = b.select{|t| t == 0}.size + n - b.uniq.size

# p b
# p n - b.uniq.size

puts ans