J=lambda:map(int,input().split()) N,K=J() A=list(J()) a=c=0 for d in range(29,-1,-1): a*=2;h={} for x in A: if x>>d in h:h[x>>d]+=1 else:h[x>>d]=1 s=c+sum((h[x]*h[x^a]if x^a in h else 0)if a else(h[x]-1)*h[x]for x in h)//2 if s