import sys # sys.setrecursionlimit(1000005) # sys.set_int_max_str_digits(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] # inf = -1-(-1 << 31) inf = -1-(-1 << 63) # md = 10**9+7 md = 998244353 class BinaryTrie: def __init__(self, max_bit_len=32): self.dd=[[0]*max_bit_len] self.cc = [0] self.to = [[-1], [-1]] self.mb = max_bit_len def add(self, a): u = 0 self.cc[u] += 1 for i in range(self.mb-1, -1, -1): d = a >> i & 1 if self.to[d][u] == -1: self.to[d][u] = len(self.cc) self.to[0].append(-1) self.to[1].append(-1) self.cc.append(0) self.dd.append([0]*self.mb) u = self.to[d][u] self.cc[u] += 1 dd=self.dd[u] for j in range(self.mb):dd[j]+=a>>j&1 def getval(self,a,x): res=[0]*self.mb ax=a^x u=0 for i in range(self.mb)[::-1]: e=ax>>i&1 v=self.to[e^1][u] if x>>i&1 and v!=-1: for j in range(self.mb): if a>>j&1: res[j]+=self.cc[v] else: res[j]+=self.dd[v][j] u=self.to[e][u] if u==-1:break return res n,x=LI() aa=LI() bt=BinaryTrie(19) dd=[0]*19 for a in aa: res=bt.getval(a,x) for j in range(19):dd[j]+=res[j] bt.add(a) ans=0 base=1 for d in dd: ans+=base*d base<<=1 print(ans)