N, M = map(int, input().split()) A = list(map(int, input().split())) if M % 2 : exit(print(0)) st = set() for i in range(N): st.add(A[i]) ans = 0 for i in range(N): if A[i] + M // 2 in st: ans += N - 2 print(ans)