n,m=map(int,input().split()) d={} for a in list(map(int,input().split())): d[a-1]=1 c=0 for v in d: if (v+m//2)%m in d: c+=n-2 print((c*(m%2==0))//2)