N, M = map(int, input().split()) A = list(map(lambda x:int(x)%M, input().split())) A.sort() Aset = set(A) if M%2: print(0) exit() ans = 0 i = 0 while i < N and A[i] < M//2: if (A[i] + M//2) % M in Aset: ans += N-2 i += 1 print(ans)