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