import sys,random input=sys.stdin.readline N,X=map(int,input().split()) A=list(map(int,input().split())) def solve_square(): a,b=X//512,X%512 data_conv = [[0 for j in range(512)] for i in range(512)] data_bit = [[0 for j in range(9)] for i in range(512)] cnt = [0 for i in range(512)] for i in range(N): x,y = A[i]//512 , A[i]%512 data_conv[x][y] += 1 cnt[x] += 1 for j in range(9): if not y>>j & 1: data_bit[x][j] += 1 def all_sum(x,y): res = 0 upper_bit = (x | y) << 9 res += upper_bit * cnt[x] * cnt[y] for i in range(9): res += (1 << i) * (cnt[x] * cnt[y] - data_bit[x][i] * data_bit[y][i]) return res def convolute(x,y): res = 0 upper_bit = (x | y) << 9 for i in range(512): for j in range(512): if i^j < b: res += (upper_bit + (i | j)) * data_conv[x][i] * data_conv[y][j] return res def all_sum_equal(x): res = 0 upper_bit = x << 9 res += upper_bit * cnt[x] * (cnt[x] - 1) // 2 for i in range(9): res += (1 << i) * (cnt[x] * (cnt[x] - 1) // 2 - (data_bit[x][i] * (data_bit[x][i] - 1) // 2)) return res def convolute_equal(x): res = 0 upper_bit = x << 9 for i in range(512): for j in range(i): if i^j < b: res += (upper_bit + (i | j)) * data_conv[x][i] * data_conv[x][j] for i in range(512): res += (upper_bit + i) * data_conv[x][i] * (data_conv[x][i] - 1) // 2 return res ans=0 for i in range(512): for j in range(i): if i^j < a: ans += all_sum(i,j) elif i^j == a: ans += convolute(i,j) for i in range(512): if 0 < a: ans += all_sum_equal(i) elif 0 == a: ans += convolute_equal(i) return ans print(solve_square())