There are some beautiful girls in Arpa’s land as mentioned before.

Once Arpa came up with an obvious problem:

Given an array and a number x, count the number of pairs of indices i, j (1 ≤ i < j ≤ n) such that $a_{i} \oplus a_{j} = x$, where $\oplus$ is bitwise xor operation (see notes for explanation).

 [Image] 

Immediately, Mehrdad discovered a terrible solution that nobody trusted. Now Arpa needs your help to implement the solution to that problem.


-----Input-----

First line contains two integers n and x (1 ≤ n ≤ 10^5, 0 ≤ x ≤ 10^5) — the number of elements in the array and the integer x.

Second line contains n integers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 10^5) — the elements of the array.


-----Output-----

Print a single integer: the answer to the problem.


-----Examples-----
Input
2 3
1 2

Output
1
Input
6 1
5 1 2 3 4 1

Output
2


-----Note-----

In the first sample there is only one pair of i = 1 and j = 2. $a_{1} \oplus a_{2} = 3 = x$ so the answer is 1.

In the second sample the only two pairs are i = 3, j = 4 (since $2 \oplus 3 = 1$) and i = 1, j = 5 (since $5 \oplus 4 = 1$).

A bitwise xor takes two bit integers of equal length and performs the logical xor operation on each pair of corresponding bits. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. You can read more about bitwise xor operation here: https://en.wikipedia.org/wiki/Bitwise_operation#XOR.

Difficulty: MEDIUM
Tags: Number theory

Mathematics

Complete search
Skill types: Complete search

Starter code:

Solutions:
(n, x) = map(int, input().split())
cnt = [0] * (1 << 18)
arr = list(map(int, input().split()))
ans = 0
for i in range(n - 1, -1, -1):
	temp = arr[i] ^ x
	ans += cnt[temp]
	cnt[arr[i]] += 1
print(ans)


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
dict = {}
for v in arr:
	if v in dict:
		dict[v] += 1
	else:
		dict[v] = 1
if x:
	res = 0
	for v in dict.keys():
		if v ^ x in dict and v ^ x > v:
			res += dict[v] * dict[v ^ x]
	print(res)
else:
	print(sum(map(lambda x: x * (x - 1) // 2, dict.values())))


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
b = [0] * int(200000.0)
for i in arr:
	b[i] += 1
res = 0
for i in arr:
	r = i ^ x
	res += b[r]
if x == 0:
	res -= len(arr)
print(res // 2)


n1 = input('')
m1 = input('')
n = n1.split(' ')
m = m1.split(' ')
ans = 0
x = int(n[1])
lst = {}
for i in m:
	a = int(i)
	if a ^ x in lst:
		ans += lst[a ^ x]
	if a in lst:
		lst[a] += 1
	else:
		lst[a] = 1
print(ans)


from sys import stdin, stdout
(n, x) = map(int, stdin.readline().split())
ar = list(map(int, stdin.readline().split()))
mp = {}
c = 0
for i in range(n):
	c += mp.get(ar[i] ^ x, 0)
	mp[ar[i]] = mp.get(ar[i], 0) + 1
stdout.write(str(c) + '\n')


(n, x) = map(int, input().split())
d = dict()
a = [int(x) for x in input().split()]
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
k = 0
for i in a:
	c = d.get(i ^ x, 0)
	if i == i ^ x:
		k += (c - 1) / 2
	else:
		k += c / 2
print(int(k))


(_, n) = map(int, input().split())
M = {}
ans = 0
for x in map(int, input().split()):
	ans += M.get(x ^ n, 0)
	M[x] = M.get(x, 0) + 1
print(ans)


def process(A, x):
	d = {}
	answer = 0
	for c in A:
		if c not in d:
			d[c] = 0
		d[c] += 1
		c2 = c ^ x
		if c2 in d:
			if c != c2:
				answer += d[c2]
			else:
				answer += d[c] - 1
	return answer
(n, x) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
print(process(A, x))


import sys, queue
try:
	import dev_act_ffc429465ab634
	DEV = True
except:
	DEV = False

def log(*s):
	if DEV:
		print('L', list(s), sep='')

class EJudge:

	def __init__(self, problem='default', reclim=1 << 30):
		self.problem = problem
		sys.setrecursionlimit(reclim)

	def use_files(self, infile='', outfile=''):
		if infile != '':
			self.infile = open(infile)
			sys.stdin = self.infile
		if infile != '':
			self.outfile = open(outfile, 'w')
			sys.stdout = self.outfile

	def use_bacs_files(self):
		self.use_files(self.problem + '.in', self.problem + '.out')

	def get_tl(self):
		while True:
			pass

	def get_ml(self):
		tmp = [[[5] * 100000 for _ in range(1000)]]
		while True:
			tmp.append([[5] * 100000 for _ in range(1000)])

	def get_re(self):
		s = (0,)[8]

	def get_wa(self, wstr='blablalblah'):
		for _ in range(3):
			print(wstr)
		exit()

class IntReader:

	def __init__(self):
		self.ost = queue.Queue()

	def get(self):
		return int(self.sget())

	def sget(self):
		if self.ost.empty():
			for el in input().split():
				self.ost.put(el)
		return self.ost.get()

	def release(self):
		res = []
		while not self.ost.empty():
			res.append(self.ost.get())
		return res
ej = EJudge()
int_reader = IntReader()
fmap = lambda f, l: list(map(f, l))
parse_int = lambda : fmap(int, input().split())
sign = lambda x: (x > 0) - (x < 0)
(n, x) = parse_int()
st = [0] * 100500
xored = [0] * 100500
for _ in range(n):
	st[int_reader.get()] += 1
for idx in range(100500):
	pair = idx ^ x
	if pair < 100500:
		xored[pair] = st[idx]
ans = 0
for idx in range(100500):
	ans += st[idx] * xored[idx]
if x == 0:
	ans -= n
print(ans // 2)


(n, x) = map(int, input().split())
a = [int(i) for i in input().split()]
m = dict()
for i in a:
	if not i in m:
		m[i] = 1
	else:
		m[i] += 1
s = 0
for i in m:
	j = x ^ i
	if j in m:
		if i == j:
			s += m[i] * (m[i] - 1)
		else:
			s += m[i] * m[j]
print(s // 2)


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
dict1 = {}
for i in range(n):
	try:
		dict1[arr[i]] += 1
	except:
		KeyError
		dict1[arr[i]] = 1
ans = 0
if x == 0:
	for i in dict1.keys():
		ans += dict1[i] * (dict1[i] - 1)
	print(ans // 2)
else:
	for i in range(n):
		val = arr[i] ^ x
		try:
			ans += dict1[val]
		except:
			KeyError
	print(ans // 2)


import math, sys, bisect, heapq, os
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
from functools import lru_cache
int1 = lambda x: int(x) - 1

def input():
	return sys.stdin.readline().rstrip('\r\n')
aj = lambda : list(map(int, input().split()))

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])

def solve():
	(n, x) = aj()
	A = aj()
	count = 0
	C = Counter(A)
	if x == 0:
		for i in C.values():
			count += i * (i - 1) // 2
		print(count)
		exit(0)
	else:
		for i in A:
			count += C[i ^ x]
		print(count // 2)
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
solve()


(n, x) = map(int, input().split())
ar = list(map(int, input().split()))
cnt = {}
ans = 0
for val in ar:
	cur = val ^ x
	if cur in cnt:
		ans += cnt[cur]
	if val in cnt:
		cnt[val] += 1
	else:
		cnt[val] = 1
print(ans)


(n, x) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
cs = {}
for v in a:
	cs[v] = cs.get(v, 0) + 1
t = 0
if x == 0:
	for c in cs.values():
		t += c * (c - 1) // 2
	print(t)
else:
	for v in a:
		t += cs.get(x ^ v, 0)
	print(t // 2)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
d = {}
for k in a:
	if d.get(k ^ x, 0) > 0:
		ans += d.get(k ^ x)
	d[k] = d.get(k, 0) + 1
print(ans)


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
cs = {}
ans = 0
for c in arr:
	ans += cs.get(c ^ x, 0)
	cs[c] = cs.get(c, 0) + 1
print(ans)


(n, x) = map(int, input().split())
z = list(map(int, input().split()))
from collections import defaultdict
al = defaultdict(int)
for i in range(len(z)):
	al[z[i]] += 1
if x == 0:
	total = 0
	z = list(set(z))
	for i in range(len(z)):
		temp = al[z[i]]
		total += temp * (temp - 1) // 2
	print(total)
	exit()
total = 0
for i in range(len(z)):
	temp = z[i] ^ x
	total += al[temp]
print(total // 2)


(n, x) = map(int, input().split())
d = {}
a = 0
for i in map(int, input().split()):
	d[i] = d.get(i, 0) + 1
for i in d:
	a += [d[i] * (d[i] - 1), d.get(i ^ x, 0) * d[i]][i != i ^ x]
print(a // 2)


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
dp = [0] * (10 ** 6 + 1)
for i in arr:
	dp[i] += 1
ans = 0
for i in arr:
	ans += dp[i ^ x]
	if x == 0:
		ans -= 1
print(ans // 2)


import sys
args = sys.stdin.readline()
(n, x) = [int(a) for a in args.split()]
args = sys.stdin.readline()
arr = [int(a) for a in args.split()]
met = {}
amount = 0
for a in arr:
	val = a ^ x
	old = met.get(val, None)
	if not old is None:
		amount += old
	old = met.get(a, 0)
	met[a] = old + 1
sys.stdout.write(str(amount))


(n, x) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
(d, c) = ({}, 0)
for i in a:
	temp = x ^ i
	if temp in d:
		c += d[temp]
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
print(c)


q = 1
for _ in range(q):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	a = [0] * (10 ** 5 + 1)
	for i in range(n):
		a[l[i]] += 1
	ans = 0
	for i in range(n):
		x = l[i] ^ k
		if x <= 10 ** 5:
			if x == l[i]:
				ans += a[l[i]] - 1
			else:
				ans += a[x]
	print(ans // 2)


def main():
	from collections import Counter
	try:
		while True:
			(n, trg) = map(int, input().split())
			a = list(map(int, input().split()))
			c = Counter(a)
			result = 0
			for x in a:
				result += c[trg ^ x]
			if trg == 0:
				result -= n
			print(result >> 1)
	except EOFError:
		pass
main()


def ri():
	return map(int, input().split())
(n, x) = ri()
cnt = 0
dd = {}
for i in ri():
	if i in dd:
		dd[i] += 1
	else:
		dd[i] = 1
	xx = i ^ x
	if xx in dd:
		cnt += dd[xx]
		if x == 0:
			cnt -= 1
print(int(cnt))


def __starting_point():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	freq = {}
	for v in a:
		freq[v] = freq.get(v, 0) + 1
	res = 0
	cfreq = {}
	for v in a:
		y = v ^ x
		cfreq[v] = cfreq.get(v, 0) + 1
		if y in freq:
			res += freq[y] - cfreq.get(y, 0)
	print(res)
__starting_point()


(n, x) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
ax = [i ^ x for i in a]
a.sort()
ax.sort()
pos = 0
posx = 0
c = 1
cx = 1
total = 0
while pos < n and posx < n:
	if a[pos] == ax[posx]:
		if pos < n - 1 and a[pos + 1] == a[pos]:
			pos += 1
			c += 1
		elif posx < n - 1 and ax[posx + 1] == ax[posx]:
			posx += 1
			cx += 1
		else:
			total += c * cx
			c = 1
			cx = 1
			pos += 1
			posx += 1
	elif a[pos] > ax[posx]:
		posx += 1
	else:
		pos += 1
if x > 0:
	print(total // 2)
else:
	print((total - n) // 2)


read = lambda : map(int, input().split())
from collections import Counter
(n, x) = read()
a = list(read())
c = Counter()
for i in a:
	c[i] += 1
cnt = 0
for i in a:
	cnt += c[i ^ x] - (x == 0)
cnt //= 2
print(cnt)


(n, x) = map(int, input().split())
l = list(map(int, input().split()))
h = [0 for x in range(2 ** 18)]
ans = 0
for i in range(n):
	need = l[i] ^ x
	ans += h[need]
	h[l[i]] += 1
print(ans)


from sys import stdin
input = stdin.buffer.readline
(n, x) = map(int, input().split())
(*a,) = map(int, input().split())
cnt = [0] * 200001
res = 0
for i in a:
	res += cnt[x ^ i]
	cnt[i] += 1
print(res)


LIMIT = 1103 + int(10000000.0)
a = [0] * LIMIT
(n, x) = map(int, input().split(' '))
r = 0
for k in [int(y) for y in input().split(' ')]:
	r += a[x ^ k]
	a[k] += 1
print(r)


from sys import stdin, stdout
import math
(n, x) = map(int, stdin.readline().split())
arr = list(map(int, stdin.readline().split()))
d = [0 for i in range(100005)]
count = 0
for i in range(len(arr)):
	if x ^ arr[i] < 100005:
		count += d[x ^ arr[i]]
	d[arr[i]] += 1
stdout.write(str(count) + '\n')


line = input().split()
N = int(line[0])
X = int(line[1])
line = input().split()
arr = [0] * 1000000
for i in range(N):
	arr[int(line[i])] += 1
res = 0
for i in range(len(arr)):
	if i ^ X < len(arr):
		if arr[i] > 0:
			if i == i ^ X:
				res += arr[i] * (arr[i] - 1) // 2
			else:
				res += arr[i] * arr[i ^ X]
		arr[i] = 0
		arr[i ^ X] = 0
print(res)


x = int(input().split(' ')[1])
a = list(map(int, input().split(' ')))
dict = {}
count = 0
for i in a:
	count += dict.get(i ^ x, 0)
	dict[i] = dict.get(i, 0) + 1
print(count)


(n, x) = map(int, input().split())
(a, c, ct) = (list(map(int, input().split())), [0 for x in range(1 << 18)], 0)
for u in a:
	ct += c[x ^ u]
	c[u] += 1
print(ct)


(n, x) = map(int, input().split())
ar = list(map(int, input().split()))
mp = {}
c = 0
for i in range(n):
	c += mp.get(ar[i] ^ x, 0)
	mp[ar[i]] = mp.get(ar[i], 0) + 1
print(c)


(n, x) = map(int, input().split())
ar = list(map(int, input().split()))
st = {}
soln = 0
for el in ar:
	if el ^ x in st:
		soln += st[el ^ x]
	if el in st:
		st[el] += 1
	else:
		st[el] = 1
print(soln)


(n, x) = map(int, input().split())
d = [0] * 100005
a = list(map(int, input().split()))
num = 0
for i in range(n):
	if x ^ a[i] < 100005:
		num += d[x ^ a[i]]
	d[a[i]] += 1
print(num)


from collections import Counter as c
a = int(input().split()[1])
b = c(map(int, input().split()))
if a:
	print(sum((b[i] * b[i ^ a] for i in b.keys())) // 2)
else:
	print(sum((b[i] * (b[i] - 1) for i in b.keys())) // 2)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
d = dict()
for i in a:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
r = 0
for i in a:
	b = i ^ x
	if b in d:
		r += d[b]
		if x == 0:
			r -= 1
r //= 2
print(r)


(n, k) = [int(x) for x in input().split()]
array = [int(x) for x in input().split()]
counter = 0
dict = {}
for i in array:
	if k ^ i in dict:
		counter += dict[k ^ i]
	if i in dict:
		dict[i] += 1
	else:
		dict[i] = 1
print(counter)


(n, x) = map(int, input().split())
(l, res) = ([0] * 131073, 0)
for a in map(int, input().split()):
	(res, l[a]) = (res + l[a ^ x], l[a] + 1)
print(res)


s = input().split()
n = int(s[0])
m = int(s[1])
a = [int(x) for x in input().split()]
frq = [0] * 100001
for i in range(n):
	frq[a[i]] += 1
ans = 0
for i in range(n):
	p = a[i] ^ m
	if p < 100001:
		if a[i] != p:
			ans += frq[p]
		else:
			ans += frq[p] - 1
ans = int(ans / 2)
print(ans)


(n, x) = map(int, input().split())
al = [0] * 1000005
m = 0
dl = list(map(int, input().split()))
ms = set(dl)
for i in dl:
	al[i] += 1
	m = max(i, m)
ans = 0
for i in ms:
	j = i ^ x
	if al[i] > 0 and al[j] > 0:
		if i != j:
			ans += al[i] * al[j]
		else:
			ans += al[i] * (al[i] - 1) // 2
		al[i] = 0
		al[j] = 0
print(ans)


def rints():
	return list(map(int, input().split()))

def ri():
	return int(input())
MAX_A = 10 ** 5
(n, x) = rints()
arr = rints()
seen = [0] * (MAX_A + 1)
count = 0
for elem in arr:
	partner = x ^ elem
	if partner <= MAX_A:
		count += seen[partner]
	seen[elem] += 1
print(count)


(n, x) = map(int, input().split(' '))
L = list(map(int, input().split()))
L = sorted(L)
P = [0] * (L[n - 1] + 1)
i = 0
while i < n:
	c = 1
	while i + c < n and L[i + c] == L[i]:
		c = c + 1
	P[L[i]] += c
	i = i + c

def binary_search(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1
count = 0
for i in range(n):
	a = L[i] ^ x
	b = binary_search(L, 0, n - 1, a)
	if b != -1 and b != i:
		count += P[L[b]]
print(count // 2)


(a, b) = map(int, input().split())
lst = list(map(int, input().split()))
n = 0
dct = {}
for x in lst:
	n += dct.get(x ^ b, 0)
	dct[x] = dct.get(x, 0) + 1
print(n)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from queue import Queue
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))[::-1]
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
INF = float('inf')
mod = 10 ** 9 + 7

def nCr(n, r):
	return fact(n) / (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res
(n, x) = MAP()
occ = defaultdict(int)
a = LIST()
for el in a:
	occ[el] += 1
if x != 0:
	ans = 0
	for el in a:
		ans += occ[el ^ x]
	print(ans // 2)
else:
	ans = 0
	for key in occ:
		if occ[key] > 1:
			ans += occ[key] * (occ[key] - 1) // 2
	print(int(ans))


(n, x) = map(int, input().split())
ip = list(map(int, input().split()))
count = 0
counts = [0 for i in range(100001)]
for i in ip:
	counts[i] += 1
for i in range(n):
	b = x ^ ip[i]
	counts[ip[i]] -= 1
	try:
		count += counts[b]
	except:
		b = 1
print(count)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import time
start_time = time.time()
import collections as col
import math, string
from functools import reduce

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	(N, X) = getInts()
	A = getInts()
	counts = col.defaultdict(int)
	for a in A:
		counts[a] += 1
	ans = 0
	if X == 0:
		for (key, val) in counts.items():
			ans += val * (val - 1) // 2
		return ans
	for (key, val) in counts.items():
		lookup = key ^ X
		if lookup in counts:
			ans += val * counts[lookup]
	return ans // 2
print(solve())


from collections import defaultdict
[n, x] = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
cnt = defaultdict(int)
for i in range(len(a)):
	ans += cnt[a[i] ^ x]
	cnt[a[i]] += 1
print(ans)


from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	(n, x) = mp()
	l = li()
	ans = 0
	d = Counter(l)
	for i in range(n):
		a = l[i] ^ x
		ans += d.get(a, 0)
		if x == 0:
			ans -= 1
	pr(ans // 2)
for _ in range(1):
	solve()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import Counter
import math
from collections import Counter
import math
import bisect
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
import bisect
cnt = 0
ls = [[] for i in range(10 ** 5 + 3)]
for i in range(n):
	ls[arr[i]].append(i)
for i in range(n):
	val = arr[i] ^ k
	if val <= 10 ** 5 and ls[val] != []:
		var = bisect.bisect_right(ls[val], i)
		cnt += max(0, len(ls[val]) - var)
print(cnt)


(n, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
if x == 0:
	ans = 0
	s = dict()
	for elem in a:
		if elem in s:
			s[elem] += 1
		else:
			s[elem] = 1
	for key in list(s.keys()):
		ans += s[key] * (s[key] - 1)
else:
	ans = 0
	s = dict()
	for elem in a:
		if elem in s:
			s[elem] += 1
		else:
			s[elem] = 1
	for key in list(s.keys()):
		if key ^ x in s:
			ans += s[key] * s[key ^ x]
print(ans // 2)


N = 10 ** 5 + 1
(n, x) = list(map(int, input().split()))
A = list(map(int, input().split()))
B = [0] * N
for a in A:
	B[a] += 1
res = 0
for i in range(N):
	if i ^ x < N:
		res += B[i] * B[i ^ x]
print((res - n) // 2 if x == 0 else res // 2)


(n, x) = map(int, input().split())
count = 0
d = {}
l = list(map(int, input().split()))
inp = l[0]
d[inp] = 1
for i in range(1, n):
	inp = l[i]
	xor = x ^ inp
	if xor in d:
		count += d[xor]
	if inp not in d:
		d[inp] = 0
	d[inp] += 1
print(count)


from collections import Counter
(n, x) = map(int, input().split())
s = list(map(int, input().split()))
s = dict(Counter(s))
ans = 0
if x == 0:
	for i in s:
		ans = ans + s[i] * (s[i] - 1) // 2
	print(ans)
	exit()
for i in s:
	a = i ^ x
	ans = ans + s.get(a, 0) * s[i]
print(ans // 2)


(n, x) = map(int, input().split())
a = [int(x) for x in input().split()]
c = 0
b = dict.fromkeys(a, 0)
for i in a:
	c += b.get(x ^ i, 0)
	b[i] = b.get(i, 0) + 1
print(c)


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
dp = [0] * (1 << 18)
ans = 0
for i in range(n):
	a = x ^ arr[i]
	ans += dp[a]
	dp[arr[i]] += 1
print(ans)


from collections import defaultdict
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
cnt = defaultdict(int)
for val in a:
	cnt[val] += 1
ret = 0
if x == 0:
	for val in cnt.values():
		ret += val * (val - 1) // 2
else:
	for val in a:
		ret += cnt[x ^ val]
	ret //= 2
print(ret)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
d = dict()
for i in range(len(a)):
	d[a[i]] = d.get(a[i], 0) + 1
res = 0

def search(num):
	l = -1
	r = len(a)
	while r - l > 1:
		m = (l + r) // 2
		if a[m] > k:
			r = m
		else:
			l = m
	return l
for i in range(len(a)):
	k = a[i] ^ x
	tr = search(k)
	if tr > -1 and tr < len(a) and (a[tr] == k):
		res += d[a[tr]]
		if a[i] == k:
			res -= 1
print(res // 2)


import sys
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
store = [0] * 1000000
cnt = 0
for i in range(n):
	num = arr[i] ^ x
	if store[arr[i] - 1] == 0:
		store[num - 1] += 1
	elif store[arr[i] - 1] >= 1:
		cnt += store[arr[i] - 1]
		store[num - 1] += 1
print(cnt)


from collections import Counter
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
if x != 0:
	c = Counter(a)
	s = set(a)
	ct = 0
	for i in range(n):
		if a[i] ^ x in s:
			ct += c[a[i] ^ x]
	print(ct // 2)
else:
	c = Counter(a)
	ct = 0
	for (k, v) in c.items():
		ct += v * (v - 1) // 2
	print(ct)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
c = [0] * 100101
for ai in a:
	c[ai] += 1
if x == 0:
	s = sum([ci * (ci - 1) for ci in c if ci > 1])
else:
	s = 0
	for i in range(1, 100101):
		if i ^ x < 100101:
			s += c[i] * c[i ^ x]
print(int(s / 2))


def solve():
	(n, x) = map(int, input().split())
	a = list(map(int, input().split()))
	d = {}
	g = []
	cnt = 0
	for i in a:
		if d.get(i) == None:
			d[i] = 1
		else:
			d[i] += 1
	for i in a:
		r = i ^ x
		if d.get(r) != None and i != r:
			cnt += d[r]
		elif d.get(r) != None and i == r:
			cnt += d[r] - 1
	print(cnt // 2)
solve()


old = [0] * 100001
new = [0] * 100001
(n, x) = (int(z) for z in input().split())
s = [int(z) for z in input().split()]
for i in s:
	old[i] += 1
	if i ^ x < 100001:
		new[i ^ x] += 1
ans = 0
for i in range(100001):
	ans += old[i] * new[i]
	if x == 0:
		ans -= old[i]
ans //= 2
print(ans)


(n, x) = map(int, input().split())
numbers = map(int, input().split())
pairs = dict()
answer = 0
for number in numbers:
	if number in pairs:
		answer += pairs[number]
	pair = number ^ x
	if pair in pairs:
		pairs[pair] += 1
	else:
		pairs[pair] = 1
print(answer)


def answer(n, x, A):
	count = 0
	d = {A[0]: 1}
	for i in range(1, n):
		if A[i] ^ x in d:
			count += d[A[i] ^ x]
		if A[i] in d:
			d[A[i]] += 1
		else:
			d[A[i]] = 1
	return count
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
print(answer(n, x, arr))


(n, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
d = {}
s = set(a)
for i in a:
	d[i] = 0
for i in a:
	d[i] += 1
ans = 0
for i in s:
	if x == 0:
		ans += d[i] * (d[i] - 1) // 2
	else:
		ans += d[i] * d.get(i ^ x, 0)
if x == 0:
	print(ans)
else:
	print(ans // 2)


from collections import Counter
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
cnt = Counter(arr)
others = {}
x = bin(x)[2:]
x = x.zfill(18)

def other(a):
	a = bin(a)[2:].zfill(18)
	b = []
	for i in range(18):
		if x[i] == '0':
			b.append(a[i])
		else:
			b.append('0' if a[i] == '1' else '1')
	b = int(''.join(b), 2)
	return b
c = 0
for i in range(n):
	if arr[i] not in others:
		o = other(arr[i])
		others[arr[i]] = o
		others[o] = arr[i]
	else:
		o = others[arr[i]]
	if o in cnt:
		c += cnt[o] - (1 if o == arr[i] else 0)
	cnt[arr[i]] -= 1
	if cnt[arr[i]] == 0:
		del cnt[arr[i]]
print(c)


import os, sys
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
d = dict()
for i in a:
	d[i] = d.get(i, 0) + 1
ans = 0
for i in d:
	t = i ^ x
	if t in d and d[t]:
		if i == t:
			ans += (d[t] - 1) * d[t] // 2
		else:
			ans += d[t] * d[i]
		d[t] = 0
	d[i] = 0
print(ans)


import math
import random
import sys
import collections

def In():
	return map(int, sys.stdin.readline().split())
input = sys.stdin.readline

def countxor():
	(n, x) = In()
	l = list(In())
	counter = collections.Counter(l)
	ans = 0
	for i in l:
		other = x ^ i
		if other == i:
			ans += counter[other] - 1
		else:
			ans += counter[other]
	return ans // 2
print(countxor())


R = lambda : map(int, input().split())
(n, x) = R()
cnts = {}
res = 0
for num in R():
	res += cnts.get(num, 0)
	cnts[x ^ num] = cnts.get(x ^ num, 0) + 1
print(res)


(a, b) = map(int, input().split())
lista = list(map(int, input().split()))
n = 0
d = dict()
for x in lista:
	n += d.get(x ^ b, 0)
	d[x] = d.get(x, 0) + 1
print(n)


[n, y] = map(int, input().split())
cnt = {}
ans = 0
a = list(map(int, input().split()))
for i in a:
	if y ^ i in cnt:
		ans += cnt[y ^ i]
	if i in cnt:
		cnt[i] += 1
	else:
		cnt[i] = 1
print(ans)


(n, x) = map(int, input().split())
l = list(map(int, input().split()))
ans = 0
mp = {i: 0 for i in l}
for i in l:
	mp[i] += 1
for i in l:
	mp[i] -= 1
	if i ^ x in mp.keys():
		ans += mp[i ^ x]
print(ans)


(n, x) = list(map(int, input().split()))
A = list(map(int, input().split()))
d1 = {}
for a in A:
	if a in d1:
		d1[a] += 1
	else:
		d1[a] = 1
keys = list(d1.keys())
keys.sort()
ans = 0
for k in keys:
	b = k ^ x
	if b > k:
		if b in d1:
			ans += d1[b] * d1[k]
	elif b == k:
		ans += d1[b] * (d1[b] - 1) // 2
print(ans)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
d = {}
for p in a:
	if p not in d:
		d[p] = 1
	else:
		d[p] += 1
cnt = 0
if x == 0:
	for k in d:
		cnt += d[k] * (d[k] - 1) // 2
	print(cnt)
else:
	for k in d:
		if k ^ x in d:
			cnt += d[k] * d[k ^ x]
	print(cnt // 2)


from collections import defaultdict

def main():
	nums = defaultdict(int)
	ret = 0
	(_, x) = map(int, input().split())
	arreglo = list(map(int, input().split()))
	for i in arreglo:
		nums[i] += 1
	if x == 0:
		for (key, val) in nums.items():
			if val <= 1:
				pass
			elif val == 2:
				ret += 1
			else:
				v = (val - 1) * val // 2
				ret += v
		print(ret)
	else:
		for i in arreglo:
			v = i ^ x
			ret += nums[v]
		print(ret // 2)
main()


(n, x) = list(map(int, input().split()))
a = list(map(int, input().split()))
M = max(a) + 1
cnt = [0 for _ in range(M)]
for num in a:
	cnt[num] += 1
res = 0
for num in range(1, M):
	if cnt[num] > 0:
		s = num ^ x
		if M > s >= num:
			res += cnt[s] * cnt[num] if s != num else (cnt[s] - 1) * cnt[s] // 2
print(res)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * 1000007
ans = 0
for i in range(0, n):
	ans += cnt[x ^ a[i]]
	cnt[a[i]] += 1
print(ans)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
count = {}
ans = 0
for i in range(n):
	if a[i] in count:
		count[a[i]] += 1
	else:
		count[a[i]] = 1
for i in range(n):
	val = a[i]
	if val ^ x in count:
		ans += count[val ^ x]
	if val ^ x == val:
		ans -= 1
print(ans // 2)


someDict = {}

def sumOfNumbers(m):
	return (m - 1) * m // 2

class Pair:

	def __init__(self, k, y):
		self.k = k
		self.y = y
(a, x) = map(lambda x: int(x), input().split())
arr = list(map(lambda x: int(x), input().split()))
for i in arr:
	if i in someDict.keys() or i ^ x in someDict.keys():
		if i in someDict.keys():
			someDict[i].k += 1
		elif i ^ x in someDict.keys():
			someDict[i ^ x].y += 1
	else:
		someDict[i] = Pair(1, 0)
counter = 0
if x == 0:
	for i in someDict.values():
		counter += sumOfNumbers(i.k)
	print(counter)
else:
	for i in someDict.values():
		counter += i.k * i.y
	print(counter)


import bisect
from itertools import accumulate, count
import os
import sys
import math
from decimal import *
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def SieveOfEratosthenes(n):
	prime = []
	primes = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if primes[p] == True:
			for i in range(p * p, n + 1, p):
				primes[i] = False
		p += 1
	for i in range(2, len(primes)):
		if primes[i] == True:
			prime.append(i)
	return prime

def primefactors(n):
	fac = []
	while n % 2 == 0:
		fac.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 2):
		while n % i == 0:
			fac.append(i)
			n = n // i
	if n > 1:
		fac.append(n)
	return fac

def factors(n):
	fac = set()
	fac.add(1)
	fac.add(n)
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			fac.add(i)
			fac.add(n // i)
	return list(fac)

def NcR(n, r):
	p = 1
	k = 1
	if n - r < r:
		r = n - r
	if r != 0:
		while r:
			p *= n
			k *= r
			m = math.gcd(p, k)
			p //= m
			k //= m
			n -= 1
			r -= 1
	else:
		p = 1
	return p

def Log2(x):
	if x == 0:
		return False
	return math.log10(x) / math.log10(2)

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
dic = {}
for i in a:
	if i in dic:
		dic[i] += 1
	else:
		dic[i] = 1
if x == 0:
	ans = 0
	for i in dic:
		ans += dic[i] * (dic[i] - 1) // 2
	print(ans)
else:
	ans = 0
	for i in range(0, len(a)):
		c = a[i] ^ x
		if c in dic:
			ans += dic[c]
	print(ans // 2)


N = 1000000
[n, x] = list(map(int, input().split()))
a = list(map(int, input().split()))
h = [0 for i in range(N)]
for i in range(n):
	h[a[i]] += 1
res = 0
for i in range(n):
	cnt = h[a[i] ^ x]
	if a[i] ^ x == a[i]:
		cnt -= 1
	res += cnt
res //= 2
print(res)


(n, x) = list(map(int, input().split()))
a = [int(x) for x in input().split()]
ad = {}
count = 0
for i in a:
	count += ad.get(i ^ x, 0)
	ad[i] = ad.get(i, 0) + 1
print(count)


(n, x) = map(int, input().split())
d = {}
ans = 0
for i in map(int, input().split()):
	ans += d.get(i ^ x, 0)
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
print(ans)


(n, x) = list(map(int, input().split()))
A = list(map(int, input().split()))
cnt = 2 ** 17 * [0]
ans = 0
for i in range(n - 1, -1, -1):
	ans += cnt[x ^ A[i]]
	cnt[A[i]] += 1
print(ans)


(n, x) = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * (10 ** 6 + 1)
for i in A:
	B[i] += 1
ans = 0
if x:
	for i in range(10 ** 5 + 1):
		ans += B[i] * B[i ^ x]
	print(ans // 2)
else:
	for i in B:
		ans += i * (i - 1) // 2
	print(ans)


(n, x) = map(int, input().split())
a = map(int, input().split())
b = dict()
ans = 0
for e in a:
	ans += b.get(e ^ x, 0)
	b[e] = b.get(e, 0) + 1
print(ans)


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f

def eprint(*args):
	print(*args, file=sys.stderr)
pl = 1
from math import *
import copy
if pl:
	input = sys.stdin.readline

def li():
	return [int(xxx) for xxx in input().split()]

def fi():
	return int(input())

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())
d = []
from bisect import *
from itertools import permutations
from bisect import *
(n, x) = mi()
a = li()
d = {}
for i in a:
	d[i] = 0
for i in a:
	d[i] += 1
ans = 1
for i in range(n):
	if a[i] ^ x == a[i]:
		ans += d[a[i]] - 1
	elif a[i] ^ x in d:
		ans += d[a[i] ^ x]
print(ans // 2)


from collections import Counter
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
d = Counter(a)
ans = 0
for i in range(n):
	d[a[i]] -= 1
	ans += d[a[i] ^ x]
print(ans)


class CodeforcesTask742BSolution:

	def __init__(self):
		self.result = ''
		self.n_x = []
		self.array = []

	def read_input(self):
		self.n_x = [int(x) for x in input().split(' ')]
		self.array = [int(x) for x in input().split(' ')]

	def process_task(self):
		nums = {}
		for a in self.array:
			if a in nums:
				nums[a] += 1
			else:
				nums[a] = 1
		pair_cnt = 0
		for a in self.array:
			b = a ^ self.n_x[1]
			if b != a:
				if b in nums:
					pair_cnt += nums[b]
			elif nums[b] > 1:
				pair_cnt += nums[b] - 1
		self.result = str(pair_cnt // 2)

	def get_result(self):
		return self.result
Solution = CodeforcesTask742BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * 200000
for c in a:
	b[c] += 1
ans = 0
for c in a:
	res = c ^ x
	ans += b[res]
	if x == 0:
		ans -= 1
print(ans // 2)


import math
(n, x) = map(int, input().split())
dic = {}
lis = list(map(int, input().split()))
for i in lis:
	dic[i] = dic.get(i, 0) + 1
se = set(lis)
output = 0
if x == 0:
	for i in dic:
		if dic[i] > 1:
			output += dic[i] * (dic[i] - 1) // 2
	print(output)
	exit()
for i in se:
	if i ^ x in dic:
		output += dic[i] * dic[i ^ x]
print(output // 2)


(n, k) = map(int, input().split())
l = [int(i) for i in input().split()]
d = {}
ans = 0
for i in l:
	ans += d.get(i ^ k, 0)
	d[i] = d.get(i, 0) + 1
print(ans)


import bisect
(n, x) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(n):
	if a[i] != a[i] ^ x:
		ans += bisect.bisect_right(a, a[i] ^ x) - bisect.bisect_left(a, a[i] ^ x)
	else:
		ans += bisect.bisect_right(a, a[i] ^ x) - bisect.bisect_left(a, a[i] ^ x) - 1
print(ans // 2)


from collections import Counter
(n, x) = map(int, input().split())
a = map(int, input().split())
(d1, d2) = (Counter(), Counter())
for el in a:
	d1[el] += 1
	d2[el ^ x] += 1
res = 0
for (el, v1) in d1.items():
	v2 = d2[el]
	res += v1 * v2 if x != 0 else v1 * (v1 - 1) // 2
print(res // 2 if x != 0 else res)


from collections import Counter
i = input().split(' ')
numbers = input().split(' ')

def result(numbers, x):
	result = 0
	counted_numbers = Counter(map(int, numbers))
	for value in counted_numbers:
		if counted_numbers[value ^ int(x)] > 0:
			if x == '0':
				result += counted_numbers[value ^ int(x)] * (counted_numbers[value] - 1)
			else:
				result += counted_numbers[value ^ int(x)] * counted_numbers[value]
	return result // 2
print(result(numbers, i[1]))


(N, X) = list(map(int, input().split()))
A = list(map(int, input().split()))
dic = {}
count = 0
for i in A:
	count += dic.get(i ^ X, 0)
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
print(count)


(n, x) = map(int, input().split())
l = list(map(int, input().split()))
xl = [0 for i in range(200002)]
cnt = 0
for i in l:
	if i == 0:
		pass
	else:
		cnt += xl[i ^ x]
		xl[i] += 1
print(cnt)


import sys, collections
ddict = collections.defaultdict
input = sys.stdin.readline
(n, x) = map(int, input().split())
al = list(map(int, input().split()))
d = ddict(int)
for a in al:
	d[a] += 1
ret1 = 0
ret2 = 0
for a in d:
	b = a ^ x
	if b in d:
		if a == b:
			ret1 += d[a] * (d[a] - 1) // 2
		else:
			ret2 += d[a] * d[a ^ x]
print(ret1 + ret2 // 2)


(n, x) = map(int, input().split())
a = [int(k) for k in input().split()]
freq = {}
ans = 0
for k in a:
	ans += freq.get(x ^ k, 0)
	freq[k] = freq.get(k, 0) + 1
print(ans)


(n, x) = map(int, input().split())
table = {}
for a in map(int, input().split()):
	if a in table:
		table[a] += 1
	else:
		table[a] = 1
ans = 0
for i in table.keys():
	if table[i] > 0:
		if i ^ x in table:
			if i == i ^ x:
				ans += table[i] * (table[i] - 1) // 2
			else:
				ans += table[i] * table[i ^ x]
			table[i ^ x] = 0
print(ans)


(n, x) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
la = [0] * int(1000000.0 + 5)
ans = 0
for i in l:
	ans += la[i ^ x]
	la[i] += 1
print(ans)


(n, x) = map(int, input().split())
cnt = [0 for i in range(100010)]
arr = list(map(int, input().split()))
for num in arr:
	cnt[num] += 1
ans = 0
for num in arr:
	xor_num = x ^ num
	if xor_num > 100000:
		continue
	cnt[num] -= 1
	if cnt[xor_num] > 0:
		ans += cnt[xor_num]
print(ans)


(a, b) = map(int, input().split())
s = list(map(int, input().split()))
from collections import Counter
s = Counter(s)
res = 0
for i in s:
	x = b ^ i
	if x == x ^ b:
		res += s.get(x) * (s.get(x) - 1)
	else:
		res += s.get(x, 0) * s.get(i)
print(res // 2)


inp = lambda : map(int, input().split())
(n, x) = inp()
a = [*inp()]
f = [0] * (10 ** 6 + 1)
ans = 0
for i in a:
	ans += f[i ^ x]
	f[i] += 1
print(ans)


from collections import Counter
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
cnt = Counter(arr)
c = 0
for i in range(n):
	o = arr[i] ^ x
	if o in cnt:
		c += cnt[o] - (1 if o == arr[i] else 0)
	cnt[arr[i]] -= 1
	if cnt[arr[i]] == 0:
		del cnt[arr[i]]
print(c)


(n, q) = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
f = {}
for i in a:
	y = i ^ q
	z = f.get(y)
	if z != None:
		ans += z
	if f.get(i) != None:
		f[i] += 1
	else:
		f[i] = 1
print(ans)


(n, x) = map(int, input().split())
a = [int(x) for x in input().split()]

def summ(n):
	ans = 0
	for i in range(n):
		ans += i
	return ans
ad = {}
count = 0
for i in a:
	ad[i] = ad.get(i, 0) + 1
if x:
	for i in ad:
		count += ad[i] * ad.get(i ^ x, 0)
	print(int(count // 2))
else:
	for i in ad:
		count += summ(ad[i])
	print(count)


(n, x) = map(int, input().split())
l = list(map(int, input().split()))
a = [0] * (10 ** 5 + 7)
for i in l:
	a[i] = a[i] + 1
c = 0
if x == 0:
	ans = 0
	for i in l:
		ans = ans + a[i] - 1
	print(ans // 2)
	exit()
for i in l:
	z = i ^ x
	if z > 10 ** 5 + 3:
		continue
	c = c + a[z]
print(c // 2)


read = lambda : map(int, input().split())
c = [0] * 100001
(n, x) = read()
a = list(read())
for v in a:
	c[v] += 1
ans = 0
for v in a:
	y = x ^ v
	if y <= 100000:
		ans += c[y]
		if y == v:
			ans -= 1
print(ans // 2)


from math import floor
(N, X) = [int(n) for n in input().split()]
nums = [int(n) for n in input().split()]
occurences = {}
for num in nums:
	res = num ^ X
	if res in occurences:
		occurences[res] += 1
	else:
		occurences[res] = 1
res = 0
if X == 0:
	for (key, val) in occurences.items():
		res += floor(val * (val - 1) / 2)
else:
	sumN = 0
	for num in nums:
		if num in occurences:
			sumN += occurences[num]
	res = floor(sumN / 2)
print(res)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
chk = []
ans = 0
for i in range(0, 100001, 1):
	chk.append(0)
for i in range(0, n, 1):
	chk[a[i]] += 1
for i in range(0, 100001, 1):
	if i ^ x <= 100000:
		if i == i ^ x:
			ans += chk[i] * (chk[i] - 1)
		else:
			ans += chk[i] * chk[i ^ x]
print(ans // 2)


(n, x) = map(int, input().split())
l = list(map(int, input().split()))
from collections import defaultdict
d = defaultdict(int)
ans = 0
for i in l:
	d[i] += 1
for j in l:
	a = j ^ x
	if d[a] > 0 and a > j:
		ans += d[a]
	elif d[a] > 0 and a == j:
		ans += d[a] * (d[a] - 1) // 2
		d[a] = 0
print(ans)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
sys.setrecursionlimit(111111)
INF = 99999999999999999999999999999999

class SortedList:

	def __init__(self, iterable=[], _load=200):
		values = sorted(iterable)
		self._len = _len = len(values)
		self._load = _load
		self._lists = _lists = [values[i:i + _load] for i in range(0, _len, _load)]
		self._list_lens = [len(_list) for _list in _lists]
		self._mins = [_list[0] for _list in _lists]
		self._fen_tree = []
		self._rebuild = True

	def _fen_build(self):
		self._fen_tree[:] = self._list_lens
		_fen_tree = self._fen_tree
		for i in range(len(_fen_tree)):
			if i | i + 1 < len(_fen_tree):
				_fen_tree[i | i + 1] += _fen_tree[i]
		self._rebuild = False

	def _fen_update(self, index, value):
		if not self._rebuild:
			_fen_tree = self._fen_tree
			while index < len(_fen_tree):
				_fen_tree[index] += value
				index |= index + 1

	def _fen_query(self, end):
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		x = 0
		while end:
			x += _fen_tree[end - 1]
			end &= end - 1
		return x

	def _fen_findkth(self, k):
		_list_lens = self._list_lens
		if k < _list_lens[0]:
			return (0, k)
		if k >= self._len - _list_lens[-1]:
			return (len(_list_lens) - 1, k + _list_lens[-1] - self._len)
		if self._rebuild:
			self._fen_build()
		_fen_tree = self._fen_tree
		idx = -1
		for d in reversed(range(len(_fen_tree).bit_length())):
			right_idx = idx + (1 << d)
			if right_idx < len(_fen_tree) and k >= _fen_tree[right_idx]:
				idx = right_idx
				k -= _fen_tree[idx]
		return (idx + 1, k)

	def _delete(self, pos, idx):
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len -= 1
		self._fen_update(pos, -1)
		del _lists[pos][idx]
		_list_lens[pos] -= 1
		if _list_lens[pos]:
			_mins[pos] = _lists[pos][0]
		else:
			del _lists[pos]
			del _list_lens[pos]
			del _mins[pos]
			self._rebuild = True

	def _loc_left(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(lo, pos) = (-1, len(_lists) - 1)
		while lo + 1 < pos:
			mi = lo + pos >> 1
			if value <= _mins[mi]:
				pos = mi
			else:
				lo = mi
		if pos and value <= _lists[pos - 1][-1]:
			pos -= 1
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value <= _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def _loc_right(self, value):
		if not self._len:
			return (0, 0)
		_lists = self._lists
		_mins = self._mins
		(pos, hi) = (0, len(_lists))
		while pos + 1 < hi:
			mi = pos + hi >> 1
			if value < _mins[mi]:
				hi = mi
			else:
				pos = mi
		_list = _lists[pos]
		(lo, idx) = (-1, len(_list))
		while lo + 1 < idx:
			mi = lo + idx >> 1
			if value < _list[mi]:
				idx = mi
			else:
				lo = mi
		return (pos, idx)

	def add(self, value):
		_load = self._load
		_lists = self._lists
		_mins = self._mins
		_list_lens = self._list_lens
		self._len += 1
		if _lists:
			(pos, idx) = self._loc_right(value)
			self._fen_update(pos, 1)
			_list = _lists[pos]
			_list.insert(idx, value)
			_list_lens[pos] += 1
			_mins[pos] = _list[0]
			if _load + _load < len(_list):
				_lists.insert(pos + 1, _list[_load:])
				_list_lens.insert(pos + 1, len(_list) - _load)
				_mins.insert(pos + 1, _list[_load])
				_list_lens[pos] = _load
				del _list[_load:]
				self._rebuild = True
		else:
			_lists.append([value])
			_mins.append(value)
			_list_lens.append(1)
			self._rebuild = True

	def discard(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_right(value)
			if idx and _lists[pos][idx - 1] == value:
				self._delete(pos, idx - 1)

	def remove(self, value):
		_len = self._len
		self.discard(value)
		if _len == self._len:
			raise ValueError('{0!r} not in list'.format(value))

	def pop(self, index=-1):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		value = self._lists[pos][idx]
		self._delete(pos, idx)
		return value

	def bisect_left(self, value):
		(pos, idx) = self._loc_left(value)
		return self._fen_query(pos) + idx

	def bisect_right(self, value):
		(pos, idx) = self._loc_right(value)
		return self._fen_query(pos) + idx

	def count(self, value):
		return self.bisect_right(value) - self.bisect_left(value)

	def __len__(self):
		return self._len

	def __getitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		return self._lists[pos][idx]

	def __delitem__(self, index):
		(pos, idx) = self._fen_findkth(self._len + index if index < 0 else index)
		self._delete(pos, idx)

	def __contains__(self, value):
		_lists = self._lists
		if _lists:
			(pos, idx) = self._loc_left(value)
			return idx < len(_lists[pos]) and _lists[pos][idx] == value
		return False

	def __iter__(self):
		return (value for _list in self._lists for value in _list)

	def __reversed__(self):
		return (value for _list in reversed(self._lists) for value in reversed(_list))

	def __repr__(self):
		return 'SortedList({0})'.format(list(self))

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		(n, x) = ria()
		a = ria()
		z = []
		for i in a:
			z.append(x ^ i)
		d = Counter(a)
		ans = 0
		if x:
			for i in z:
				ans += d[i]
		else:
			for i in z:
				ans += d[i] - 1
		wi(ans // 2)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


from collections import Counter, OrderedDict
from itertools import permutations as perm
from fractions import Fraction
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
from math import *
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(n, x) = gil()
a = gil()
b = Counter(a)
ans = 0
if x:
	for v in a:
		ans += b.get(x ^ v, 0)
	print(ans // 2)
else:
	for v in b.values():
		ans += v * (v - 1) // 2
	print(ans)


def sum(x):
	return int(x * (x + 1) / 2)
from collections import Counter
from math import factorial
answer = 0
seen = {}
ri = input()
ri = ri.split()
n = int(ri[0])
x = int(ri[1])
ri = input()
ri = ri.split()
d = Counter(ri)
for v1 in list(d.keys()):
	v2 = str(int(v1) ^ x)
	if v2 in d:
		if v1 == v2:
			answer += sum(d[v1] - 1)
			del d[v1]
		else:
			answer += d[v1] * d[v2]
			del d[v1]
			del d[v2]
print(answer)


def main():
	(n, x) = list(map(int, input().split()))
	(l, res) = ([0] * 131073, 0)
	for a in map(int, input().split()):
		res += l[a ^ x]
		l[a] += 1
	print(res)

def __starting_point():
	main()
__starting_point()


temp = input().split()
n = int(temp[0])
x = int(temp[1])
temp = input().split()
a = [int(k) for k in temp]
c = [0 for i in range(10 ** 5 + 1)]
for i in range(n):
	c[a[i]] += 1
ans = 0
for i in range(n):
	if a[i] ^ x <= 10 ** 5:
		ans += c[a[i] ^ x]
if x == 0:
	ans -= n
ans = int(ans / 2)
print(ans)


def get_row():
	return [int(x) for x in input().split()]
(_, x) = get_row()
a = get_row()
counts = {}
count = 0
for n in reversed(a):
	count += counts.get(n ^ x, 0)
	counts[n] = counts.get(n, 0) + 1
print(count)


(n, x) = map(int, input().split())
di = {}
answer = 0
for v in map(int, input().split()):
	answer += di.get(v ^ x, 0)
	di[v] = di.get(v, 0) + 1
print(answer)


from collections import *
(n, x) = map(int, input().split())
a = list(map(int, input().split()))
d = defaultdict(lambda : 0)
for i in a:
	d[i] += 1
cn = 0
for i in a:
	d[i] -= 1
	cn += d[i ^ x]
print(cn)


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
from collections import Counter
cnt = Counter(arr)
ans = 0
for v in cnt.keys():
	if v == v ^ x:
		ans += cnt.get(v) * (cnt.get(v) - 1)
	else:
		ans += cnt.get(v) * cnt.get(v ^ x, 0)
print(ans // 2)


(n, x) = map(int, input().split())
a = list(map(int, input().split()))
cnt = [0] * int(1000000.0)
ans = 0
for val in a:
	ans += cnt[val ^ x]
	cnt[val] += 1
print(ans)


import bisect

def l_b(a, x):
	l = -1
	r = len(a)
	while r - l > 1:
		m = (l + r) // 2
		if a[m] < x:
			l = m
		else:
			r = m
	return r

def u_b(a, x):
	l = -1
	r = len(a)
	while r - l > 1:
		m = (l + r) // 2
		if a[m] <= x:
			l = m
		else:
			r = m
	return r
(n, x) = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans = 0
for i in range(len(a)):
	y = a[i] ^ x
	ans += bisect.bisect_right(a, y) - bisect.bisect_left(a, y)
	if a[i] ^ x == a[i]:
		ans -= 1
print(ans // 2)


from sys import stdin, stdout
import sys
import math
INF = 1000000000.0

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
from collections import defaultdict
(n, x) = get_ints()
a = get_array()
d = defaultdict(int)
c = 0
for i in a:
	if d[i ^ x]:
		c += d[i ^ x]
	d[i] += 1
print(c)


from collections import Counter
from sys import stdin, stdout
(n, x) = map(int, stdin.readline().split(' '))
ass = list(map(int, stdin.readline().split(' ')))
cnts = Counter(ass)
r = -n if x == 0 else 0
for a in ass:
	r += cnts[a ^ x]
stdout.write(str(r // 2) + '\n')


from collections import *
(n, x) = map(int, input().split())
l = list(map(int, input().split()))
d = defaultdict(int)
for i in l:
	d[i] += 1
c = 0
for i in range(n):
	s = l[i] ^ x
	if s == l[i]:
		c += d[l[i]] - 1
	else:
		c += d[s]
print(c // 2)


def cin():
	return list(map(int, input().split()))
N = int(1000000.0 + 5)
(n, x) = cin()
A = cin()
B = [0] * N
an = 0
for i in A:
	an += B[i ^ x]
	B[i] += 1
print(an)


from collections import defaultdict
(n, x) = [int(i) for i in input().split()]
arr = [int(i) for i in input().split()]
Dict = defaultdict(int)
ans = 0
for i in range(n):
	temp = arr[i] ^ x
	ans += Dict[temp]
	Dict[arr[i]] += 1
print(ans)


from collections import Counter, defaultdict, deque
import heapq as hq
import math
import sys
input = sys.stdin.readline

def solve():
	(n, x) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	c = Counter(arr)
	ans = 0
	for el in arr:
		ans += c[el ^ x]
		ans -= 1 * (x == 0)
	print(ans // 2)
tt = 1
for test in range(tt):
	solve()


from collections import defaultdict
from functools import reduce
[n, X] = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
cnt = defaultdict(int)

def func(y, x):
	ret = y + cnt[x ^ X]
	cnt[x] += 1
	return ret
print(reduce(func, a, 0))


(n, x) = [int(i) for i in input().split()]
ans = 0
d = {}
for i in map(int, input().split()):
	ans += d.get(i ^ x, 0)
	d[i] = d.get(i, 0) + 1
print(ans)


(n, x) = map(int, input().split())
lis = list(map(int, input().split()))
ans = 0
has = [0] * 1000000
for i in lis:
	has[i] += 1
ans = 0
if x == 0:
	for i in range(1000000):
		ans += has[i] * (has[i] - 1) // 2
else:
	for i in range(n):
		a = lis[i] ^ x
		ans += has[lis[i]] * has[a]
		has[lis[i]] = 0
		has[a] = 0
print(ans)


(n, x) = list(map(int, input().split()))
if x == 0:
	ans = -n
else:
	ans = 0
a = list(map(int, input().split()))
b = {}
for i in a:
	if i in b:
		b[i] += 1
	else:
		b[i] = 1
for i in a:
	k = i ^ x
	if k in b:
		ans += b[k]
print(ans // 2)


(_, X) = map(int, input().split())
l_n = list(map(int, input().split()))
d = {}
t = 0
for n in l_n:
	if n ^ X in d:
		t += d[n ^ X]
	if n not in d:
		d[n] = 0
	d[n] += 1
print(t)


(n, k) = map(int, input().split())
num = list(map(int, input().split()))
ans = 0
map = dict()
for x in num:
	y = x ^ k
	if y in map:
		ans += map[y]
	if x not in map:
		map[x] = 0
	map[x] += 1
print(ans)


(n, x) = map(int, input().split())
l = list(map(int, input().split()))
d = {}
ans = 0
for i in l:
	d[i] = d.get(i, 0) + 1
if x == 0:
	ans -= n
	for y in d:
		ans += d[y] * (d[y] + 1) // 2
else:
	for y in d:
		t = x ^ y
		ans += d[y] * d.get(t, 0)
		d[y] = 0
print(max(0, ans))


(x, y) = [int(x) for x in input().split()]
mass = [int(y) for y in input().split()]
dic_el = {}
pairs = 0
for i in mass:
	summ = i ^ y
	pairs += dic_el.get(i, 0)
	dic_el[summ] = dic_el.get(summ, 0) + 1
print(pairs)


(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
d = {}
for i in arr:
	if i in d.keys():
		d[i] += 1
	else:
		d[i] = 1
count = 0
for i in arr:
	if i ^ x in d.keys():
		if x == 0:
			if d[i ^ x] > 1:
				count += d[i] - 1
		else:
			count += d[i ^ x]
print(count // 2)


(n, x) = map(int, input().split())
(a, s) = ([0] * 100001, 0)
for i in map(int, input().split()):
	a[i] += 1
for i in range(100001):
	if not x:
		s += a[i] * (a[i] - 1) // 2
		a[i] = 0
	elif x ^ i < 100001:
		s += a[i] * a[x ^ i]
		a[i] = a[x ^ i] = 0
print(s)


(n, x) = map(int, input().split())
A = list(map(int, input().split()))
d = dict()
for j in range(n):
	if A[j] in d:
		d[A[j]] += 1
	else:
		d[A[j]] = 1
ans = 0
for j in range(n):
	per = x ^ A[j]
	if A[j] != per:
		if per in d:
			ans += d[per]
	elif per in d:
		ans += d[per] - 1
print(ans // 2)


from math import ceil
from math import floor
from math import sqrt
from math import log
prime = pow(10, 9) + 7

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def get_count_pairs(n, X, arr):
	count = 0
	mp = {}
	for i in range(n):
		if arr[i] not in mp:
			mp[arr[i]] = 0
		mp[arr[i]] += 1
	if X == 0:
		arr = set(arr)
		arr = list(arr)
		n = len(arr)
	for i in range(n):
		exor = arr[i] ^ X
		if exor in mp:
			if X == 0:
				count += int(mp[exor] * (mp[exor] - 1) / 2)
			else:
				count += mp[exor]
	if X > 0:
		count //= 2
	return count

def are_same(arr, b):
	a1 = list()
	b1 = list()
	a1 = arr.copy()
	b1 = b.copy()
	a1.sort()
	b1.sort()
	return a1 == b1

def find_xmin(n, m, arr, b):
	mn = m
	if are_same(arr, b):
		return 0
	for i in range(n):
		x = (b[0] - arr[i]) % m
		if x < 0:
			x += m
		c = []
		for j in range(n):
			c.append((arr[j] + x) % m)
		if are_same(c, b):
			mn = min(mn, x)
	return mn

def find_divisors(x):
	divisors = []
	for i in range(2, int(sqrt(x)) + 1):
		if x % i == 0:
			if x == i * i:
				divisors.append(i)
			else:
				divisors.append(i)
				divisors.append(int(x / i))
	return divisors

def find_min(N, d):
	N = str(N)
	d = str(d)
	for i in range(len(N) - 1, -1):
		print(N[i])
		if int(N[i]) > int(d):
			N = ''.join([N[j] for j in range(len(N)) and j != i])
			N += d
	return N
t = 1
while t:
	t = t - 1
	count = 0
	(n, X) = map(int, input().split())
	arr = list(map(int, input().strip().split()))[:n]
	print(get_count_pairs(n, X, arr))


(n, x) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
m = [0] * (1000000 + 1)
ans = 0
for i in range(n):
	b = a[i] ^ x
	ans += m[b]
	m[a[i]] += 1
print(ans)


(_, n) = map(int, input().split())
M = {}
ans = 0
for x in map(int, input().split()):
	ans += M.get(x ^ n, 0)
	if x not in M:
		M[x] = 1
	else:
		M[x] += 1
print(ans)