def f(a,b,n):
    c = []
    for i in range(len(b)-1):
        c.append(b[i]+a[i+n+1])
    return c

n,m = map(int, input().split())
a = [int(i) for i in input().split()]

ans = 0
b=a[:]
l=0
for i in range(n):
    for j in b:
        if j % m == 0:
            ans += 1
    b = f(a,b,l)
    # print(l,ans,b)
    l+=1


print(ans)
