After you had helped George and Alex to move in the dorm, they went to help their friend Fedor play a new computer game «Call of Soldiers 3».

The game has (m + 1) players and n types of soldiers in total. Players «Call of Soldiers 3» are numbered form 1 to (m + 1). Types of soldiers are numbered from 0 to n - 1. Each player has an army. Army of the i-th player can be described by non-negative integer x_{i}. Consider binary representation of x_{i}: if the j-th bit of number x_{i} equal to one, then the army of the i-th player has soldiers of the j-th type. 

Fedor is the (m + 1)-th player of the game. He assume that two players can become friends if their armies differ in at most k types of soldiers (in other words, binary representations of the corresponding numbers differ in at most k bits). Help Fedor and count how many players can become his friends.


-----Input-----

The first line contains three integers n, m, k (1 ≤ k ≤ n ≤ 20; 1 ≤ m ≤ 1000).

The i-th of the next (m + 1) lines contains a single integer x_{i} (1 ≤ x_{i} ≤ 2^{n} - 1), that describes the i-th player's army. We remind you that Fedor is the (m + 1)-th player.


-----Output-----

Print a single integer — the number of Fedor's potential friends.


-----Examples-----
Input
7 3 1
8
5
111
17

Output
0

Input
3 3 3
1
2
3
4

Output
3

Source: codeforces | Difficulty: EASY
Tags: Complete search

Bit manipulation

Implementation

Constructive algorithms


Solutions:
arr = []
(n, m, k) = [int(x) for x in input().split()]
c = 0
for i in range(0, m + 1, 1):
	x = int(input())
	arr.insert(i, x)
t = arr.pop(m)
for i in range(m - 1, -1, -1):
	x = arr.pop(i)
	x = x ^ t
	if bin(x).count('1') <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	x = int(input())
	t = []
	for i in range(n):
		t.append(x % 2)
		x //= 2
	t.reverse()
	a.append(t)
ans = 0
for i in range(m):
	p = 0
	for j in range(n):
		p += (a[i][j] + a[-1][j]) % 2
	if p <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
c = 0
l = []
for _ in range(m + 1):
	l.append(int(input()))
for i in range(m):
	if bin(l[i] ^ l[-1]).count('1') <= k:
		c += 1
print(c)


(n, m, k) = list(map(int, input().split()))
players = [int(input()) for count in range(m)]
fedor = int(input())
list1 = list(map(lambda x: True if str(bin(fedor ^ x))[2:].count('1') <= k else False, players))
print(list1.count(True))


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
count = 0
c = a[m]
for i in range(m):
	if bin(c ^ a[i])[2:].count('1') <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	z = int(input())
	l.append(z)
f = 0
for i in range(m):
	t = 0
	for j in range(n):
		if l[i] >> j & 1 != l[m] >> j & 1:
			t += 1
	if t <= k:
		f += 1
print(f)


(n, m, k) = map(int, input().split())
A = [bin(int(input()))[2:] for _ in range(m + 1)]
for i in range(m + 1):
	A[i] = '0' * (n - len(A[i])) + A[i]
F = A[m]
friends = 0
for i in range(m):
	counter = 0
	for j in range(n):
		if A[i][j] != F[j]:
			counter += 1
	if counter <= k:
		friends += 1
print(friends)


(n, m, k) = [int(i) for i in input().split()]
a = []
for i in range(m + 1):
	t = str(bin(int(input())))[2:]
	a.append((n - len(t)) * '0' + t)
c = 0
for i in range(m):
	f = 0
	for j in range(n):
		if a[i][j] != a[-1][j]:
			f += 1
	if f <= k:
		c += 1
print(c)


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
(n, m, k) = iia()
arr = []
for i in range(m):
	arr.append(ii1())
fed = ii1()
fedb = bin(fed)[2:]
res = 0
for i in arr:
	if fed == i:
		res += 1
	else:
		count = k
		t = bin(i)[2:]
		siz = max(len(fedb), len(t))
		t = '0' * (siz - len(t)) + t
		t1 = '0' * (siz - len(fedb)) + fedb
		for (l, m) in zip(t, t1):
			if l != m:
				if count == 0:
					break
				count -= 1
		else:
			res += 1
print(res)


(n, m, l) = input().split(' ')
n = int(n)
m = int(m)
l = int(l)
b = []
for i in range(m):
	c = input()
	c = int(c)
	b.append(c)
d = int(input())
g = 0
for i in b:
	e = i ^ d
	f = 0
	while e > 0:
		if e % 2 == 1:
			f += 1
		e = e // 2
	if f <= l:
		g += 1
print(g)


(n, m, k) = [int(x) for x in input().split()]
valz = []
for x in range(m + 1):
	valz.append(bin(int(input()))[2:].zfill(n))
e = valz[-1]
f = 0
for y in valz[:-1]:
	g = 0
	for z in range(n):
		if y[z] != e[z]:
			g += 1
	if g <= k:
		f += 1
print(f)


(n, m, k) = list(map(int, input().split()))
x = []
for i in range(m + 1):
	x.append(int(input()))
fedor = x[m]
ans = 0
for i in range(m):
	fr = x[i]
	fed = fedor
	count = 0
	while fr > 0 or fed > 0:
		count += (fr % 2 + fed % 2) % 2
		fr //= 2
		fed //= 2
	if count <= k:
		ans += 1
print(ans)


from collections import Counter
(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	l.append(int(input()))
f = l[m]
count = 0
for i in range(m):
	x = Counter(bin(f ^ l[i])[2:])
	if x['1'] <= k:
		count += 1
print(count)


def count(y):
	s = 0
	for i in y:
		if i == '1':
			s += 1
	return s
(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	a = int(input())
	l.append(a)
res = 0
f = l[-1]
for i in range(m):
	x = l[i]
	y = bin(f ^ x)
	c = count(y)
	if c <= k:
		res += 1
print(res)


l1 = [int(x) for x in input().split()]
n = l1[0]
m = l1[1]
k1 = l1[2]
l2 = []
out = 0
for i in range(0, m + 1):
	inp = int(input())
	l2.append(inp)
b2 = str(bin(l2[len(l2) - 1]))
l3 = []
for i in range(2, len(b2)):
	l3.append(b2[i])
for i in range(0, len(l2) - 1):
	b1 = str(bin(l2[i]))
	l4 = []
	for j in range(2, len(b1)):
		l4.append(b1[j])
	k = len(l4) - 1
	m1 = len(l3) - 1
	enemy = 0
	while k >= 0 or m1 >= 0:
		if k >= 0 and m1 >= 0:
			if l3[m1] != l4[k]:
				enemy += 1
		elif k >= 0 and m1 < 0:
			if l4[k] == '1':
				enemy += 1
		elif m1 >= 0 and k < 0:
			if l3[m1] == '1':
				enemy += 1
		m1 -= 1
		k -= 1
	if enemy <= k1:
		out += 1
print(out)


def can_be_friends(score, k):
	bit_count = 0
	while score:
		score = score & score - 1
		bit_count += 1
	if bit_count > k:
		return 0
	return 1

def main():
	(n, m, k) = map(int, input().split())
	players = []
	for __ in range(m):
		players.append(int(input()))
	you = int(input())
	friends = 0
	for i in players:
		friends += can_be_friends(you ^ i, k)
	print(friends)
main()


(n, m, k) = map(int, input().split())
x = [int(input()) for t in range(m + 1)]
print(sum((bin(x[m] ^ i).count('1') <= k for i in x)) - 1)


(n, m, k) = [int(i) for i in input().split()]
l = []
for i in range(m):
	a = int(input())
	l.append(a)
x = int(input())
s = 0
for i in range(m):
	c = 0
	t = bin(l[i] ^ x)
	for j in t:
		if j == '1':
			c += 1
		if c > k:
			break
	else:
		s += 1
print(s)


(n, m, k) = map(int, input().split())

def bin1(x):
	t = []
	while x > 1:
		t.append(str(x % 2))
		x //= 2
	t.append(str(x))
	t.reverse()
	y = ''.join(t)
	return y
d = []
for i in range(m + 1):
	a = int(input())
	b = bin1(a)
	d.append(b)
e = d[-1]
z = 0
for i in range(m):
	if len(d[i]) > len(e):
		e = '0' * (len(d[i]) - len(e)) + e
	elif len(d[i]) < len(e):
		d[i] = '0' * (len(e) - len(d[i])) + d[i]
	f = 0
	for j in range(len(e)):
		if e[j] != d[i][j]:
			f += 1
			if f > k:
				break
	if f <= k:
		z += 1
print(z)


def bitCount(int_type):
	count = 0
	while int_type:
		int_type &= int_type - 1
		count += 1
	return count
nmk = [int(x) for x in input().split()]
(n, m, k) = (nmk[0], nmk[1], nmk[2])
players = [int(input()) for x in range(m + 1)]
potential_friends = 0
for player in players[:m]:
	if bitCount(player ^ players[m]) <= k:
		potential_friends += 1
print(potential_friends)


(n, m, k) = map(int, input().split())
l = []
ans = 0
for i in range(m + 1):
	if i != m:
		l.append(int(input()))
	else:
		num = int(input())
		for j in l:
			s = 0
			for bit in bin(j ^ num)[2:]:
				if bit == '1':
					s += 1
			if s <= k:
				ans += 1
print(ans)


(n, m, k) = map(int, input().strip().split(' '))
x = []
for i in range(m + 1):
	x.append(int(input()))
q = 0
for i in range(m):
	if bin(x[i] ^ x[m])[2:].count('1') <= k:
		q += 1
print(q)


(n, m, k) = map(int, input().split())
l = 0
a = []
for i in range(m):
	a.append(int(input()))
x = int(input())
for i in range(m):
	if bin(a[i] ^ x).count('1') <= k:
		l += 1
print(l)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
c = 0
for i in range(m):
	one = a[i] | a[-1]
	x = bin(one)[2:].count('1')
	two = a[i] & a[-1]
	y = bin(two)[2:].count('1')
	if x - y <= k:
		c += 1
print(c)


(n, m, k) = [int(i) for i in input().split()]
(a, ans) = ([], 0)
for i in range(m):
	a.append(int(input()))
x = int(input())
for i in a:
	dif = 0
	for bit in range(n):
		dif += i >> bit & 1 != x >> bit & 1
	ans += dif <= k
print(ans)


def b(n, num):
	binary = bin(num)[2:]
	return '0' * (n - len(binary)) + binary

def friends(k, fedor, player):
	c = 0
	for (i, bit) in enumerate(fedor):
		if bit != player[i]:
			c += 1
	return c <= k
(n, m, k) = map(int, input().split())
players = []
for i in range(m):
	players.append(b(n, int(input())))
fedor = b(n, int(input()))
c = 0
for p in players:
	if friends(k, fedor, p):
		c += 1
print(c)


import sys
import math

def bitcount(n):
	count = 0
	while n > 0:
		if n & 1 == 1:
			count += 1
		n >>= 1
	return count
(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
b = int(input())
count = 0
for j in a:
	if bitcount(j ^ b) <= k:
		count += 1
print(count)


def no_diff_bits(a, b):
	maxi = max(a, b)
	mini = min(a, b)
	counter = 0
	while maxi != 0:
		r1 = maxi % 2
		maxi = maxi // 2
		r2 = mini % 2
		mini = mini // 2
		if r1 != r2:
			counter = counter + 1
	return counter
(n, m, k) = [int(x) for x in input().split()]
c = []
for i in range(m + 1):
	x = int(input())
	c.append(x)
counter = 0
for i in range(m):
	diff = no_diff_bits(c[i], c[m])
	if diff <= k:
		counter = counter + 1
print(counter)


t = list(map(int, input().split()))
n = t[0]
m = t[1]
k = t[2]

def binary_conv(n, d):
	quo = n
	arr = []
	while True:
		if quo == 0:
			break
		n = quo
		quo = n // 2
		rem = n % 2
		arr.append(rem)
	if len(arr) != d:
		yo = d - len(arr)
		for i in range(yo):
			arr.append(0)
	arr = arr[::-1]
	return arr
game = []
for i in range(m + 1):
	x = int(input())
	game.append(binary_conv(x, n))
ans = 0
for u in range(m):
	count = 0
	for j in range(n):
		if game[u][j] != game[m][j]:
			count += 1
		if count > k:
			break
	if count <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
(a, t) = ([], 0)
for i in range(m + 1):
	a.append(bin(int(input()))[2:])
for i in range(m):
	diff = 0
	if len(a[i]) > len(a[-1]):
		a[-1] = '0' * (len(a[i]) - len(a[-1])) + a[-1]
	else:
		a[i] = '0' * (len(a[-1]) - len(a[i])) + a[i]
	for j in range(len(a[i])):
		if a[i][j] != a[-1][j]:
			diff += 1
	if diff <= k:
		t += 1
print(t)


def binary(number):
	li = []
	while number != 0:
		z = number % 2
		li.append(z)
		number = int((number - z) / 2)
	if number == 0:
		li.append(0)
	return li
g = input()
(n, m, k) = [int(x) for x in g.split()]
gamers = {}
for i in range(1, m + 2):
	f = int(input())
	gamers[i] = binary(f)
listing = gamers[m + 1]
fedor = len(listing)
count = 0
for j in range(1, m + 1):
	l = 0
	t = 0
	faltu = gamers[j]
	fa = len(faltu)
	for itr in range(min(len(listing), len(faltu))):
		if faltu[itr] != listing[itr]:
			l = l + 1
		if l > k:
			t = 1
			break
	if fedor > fa:
		for it in listing[fa:]:
			if it == 1:
				l = l + 1
			if l > k:
				t = 1
				break
	if fedor < fa:
		for itt in faltu[fedor:]:
			if itt == 1:
				l = l + 1
			if l > k:
				t = 1
				break
	if t == 0:
		count += 1
print(count)


from sys import stdin, stdout

def solve(players, n, m, k):
	count = 0
	fedor = players.pop()
	for player in players:
		t = 0
		for i in range(n):
			if player >> i & 1 != fedor >> i & 1:
				t += 1
		if t <= k:
			count += 1
	return count
(n, m, k) = list(map(int, stdin.readline().strip().split()))
players = []
while m > -1:
	m -= 1
	players.append(int(stdin.readline().strip()))
stdout.write(str(solve(players, n, m, k)))


(n, m, k) = list(map(int, input().split()))
arr = []
l = 0
for i in range(m + 1):
	x = int(input())
	y = bin(x)
	y = y.split('b')[1]
	l = max(l, len(y))
	arr.append(y)
for i in range(m + 1):
	arr[i] = '0' * (l - len(arr[i])) + arr[i]
us = arr[-1]
ans = 0
for i in range(m):
	t = 0
	for j in range(l):
		if arr[i][j] != us[j]:
			t += 1
	if t <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
d = []
for i in range(m + 1):
	d.append(int(input()))
a = d.pop()

def to_binary(s, n):
	c = []
	while s:
		c.append(s % n)
		s = s // n
	return c[::-1]
cnt = 0
for i in d:
	b = a ^ i
	if sum(to_binary(b, 2)) <= k:
		cnt += 1
print(cnt)


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
a = [0] * m
for i in range(m):
	a[i] = int(input())
f = int(input())
c = 0
for i in range(m):
	cu = f ^ a[i]
	count = 0
	while cu > 0:
		if cu & 1 == 1:
			count += 1
		cu >>= 1
	if count <= k:
		c += 1
print(c)


(X, Soldiers) = (list(map(int, input().split())), [])
for i in range(X[1] + 1):
	Soldiers.append(int(input()))
print(sum([bin(Soldiers[i] ^ Soldiers[-1]).count('1') <= X[2] for i in range(X[1])]))


(n, m, k) = map(int, input().split())
arr = [int(input()) for i in range(m + 1)]
print(sum([bin(arr[m] ^ a).count('1') <= k for a in arr]) - 1)


(n, m, k) = list(map(int, input().split()))
a = []
for i in range(m + 1):
	a.append(int(input()))
cnt = 0
for i in range(m):
	l = a[-1] ^ a[i]
	c = 0
	while l > 0:
		c += 1
		l = l & l - 1
	if c <= k:
		cnt += 1
print(cnt)


import sys

def calc_ones(n):
	ret = 0
	while n > 0:
		ret += n & 1
		n >>= 1
	return ret
(n, m, k) = map(int, sys.stdin.readline().split())
army = [0] * (m + 1)
for i in range(m + 1):
	army[i] = int(input())
result = 0
for i in range(m):
	if calc_ones(army[i] ^ army[m]) <= k:
		result += 1
print(result)


def bin_dist(xx, yy):
	return sum((abs(int(x) - int(y)) for (x, y) in zip(xx, yy)))

class CodeforcesTask467BSolution:

	def __init__(self):
		self.result = ''
		self.n_m_k = []
		self.armies = []

	def read_input(self):
		self.n_m_k = [int(x) for x in input().split(' ')]
		for _ in range(self.n_m_k[1] + 1):
			self.armies.append(int(input()))

	def process_task(self):
		bins = ['0' * (self.n_m_k[0] - len(bin(x)[2:])) + bin(x)[2:] for x in self.armies]
		self.result = str(sum((1 if bin_dist(bins[-1], x) <= self.n_m_k[2] else 0 for x in bins[:-1])))

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


(n, m, k) = map(int, input().split())
players = []
for x in range(m + 1):
	players.append(int(input()))

def countbin(num):
	b = bin(num)[2:]
	count = 0
	for x in range(len(b)):
		if b[x] == '1':
			count += 1
	return count
friends = 0
for x in range(m):
	if countbin(players[m] ^ players[x]) <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
x = list((int(input()) for _ in range(m + 1)))
print(sum([bin(x[m] ^ y).count('1') <= k for y in x]) - 1)


(n, m, k) = [int(i) for i in input().split()]
players = []
for i in range(m + 1):
	players.append(int(input()))
fedor = players[m]
friends = 0
for i in range(m):
	if bin(fedor ^ players[i]).count('1') <= k:
		friends += 1
print(friends)


s = input().split(' ')
n = int(s[0])
m = int(s[1])
k = int(s[2])
x = []
a = 0
for i in range(m):
	s = bin(int(input()))[2:]
	x.append(s)
player = bin(int(input()))[2:]
for i in x:
	if len(i) > len(player):
		player = '0' * (len(i) - len(player)) + player
	else:
		i = '0' * (len(player) - len(i)) + i
	lol = 0
	for j in range(len(i)):
		if i[j] != player[j]:
			lol += 1
			if lol > k:
				break
	if lol <= k:
		a += 1
print(a)


nmk = list(map(int, input().split()))
(m, k, a) = (nmk[1], nmk[2], [])
for i in range(0, m + 1):
	a += [int(input())]
for i in range(0, m):
	a[i] = list(map(int, bin(a[i] ^ a[m])[2:]))
l = list(map(sum, a[:m]))
print(len([x for x in l if x <= k]))


(n, m, k) = [int(i) for i in input().split()]
player = []
for j in range(m + 1):
	player.append(list('{0:b}'.format(int(input()))))
	if len(player[j]) != n:
		temp = ['0'] * (n - len(player[j]))
		temp.extend(player[j])
		player[j] = temp
friend = 0
for t in range(m):
	cnt = 0
	for l in range(n):
		if player[t][l] != player[m][l]:
			cnt += 1
		if cnt > k:
			break
		elif l == n - 1:
			friend += 1
print(friend)


def main():
	(n, m, k) = list(map(int, input().split()))
	a = []
	for _ in range(m):
		a.append(int(input()))
	f = int(input())

	def bitcnt(i):
		c = 0
		while i:
			i &= i - 1
			c += 1
		return c
	res = 0
	for ai in a:
		if bitcnt(ai ^ f) <= k:
			res += 1
	print(res)

def __starting_point():
	main()
__starting_point()


(n, m, k) = map(int, input().split())
l = [int(input()) for x in range(m)]
a = int(input())
s = 0
for x in range(m):
	d = bin(a ^ l[x])[2:]
	if d.count('1') <= k:
		s += 1
print(s)


(n, m, k) = map(int, input().split(' '))
L = []
for i in range(m):
	L.append(int(input()))
Fedor = int(input())
res = 0
for i in L:
	x = Fedor ^ i
	if bin(x).count('1') <= k:
		res += 1
print(res)


(n, m, k) = list(map(int, input().split()))
a = []
c = 0
for i in range(m):
	b = int(input())
	a.append('{0:b}'.format(b))
t1 = '{0:b}'.format(int(input()))
for i in range(m):
	t2 = list(str(int(a[i]) + int(t1)))
	k1 = 0
	p = 0
	for j in range(len(t2)):
		if int(t2[j]) % 2 != 0:
			k1 += 1
		if k1 > k:
			p = 1
			break
	if p == 0:
		c += 1
print(c)


def check_differ(teammate, fedor, differ_limit):
	match = True
	differ_count = 0
	for i in range(0, len(teammate)):
		if teammate[i] != fedor[i]:
			differ_count += 1
		if differ_count > differ_limit:
			match = False
			break
	return match
(solder_types, teammates, differ_limit) = map(int, input().split())
player = [None] * (teammates + 1)
friends = 0
for i in range(len(player)):
	player[i] = bin(int(input()))[2:].zfill(solder_types)
for i in range(len(player) - 1):
	if check_differ(list((bit for bit in player[i])), list((bit for bit in player[-1])), differ_limit):
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
data = [0] * m
data = [int(input()) for i in range(m)]
f = int(input())

def sum_bits(v, n):
	res = 0
	for i in range(n):
		res += v & 1 << i != 0
	return res
diffs = (sum_bits(f ^ v, n) for v in data)
diffs = map(lambda v: v <= k, diffs)
print(sum(diffs))


l = input().split()
m = int(l[1])
k = int(l[2])
arr = []
res = 0
for i in range(m + 1):
	arr.append(int(input()))
for i in range(len(arr) - 1):
	xor = arr[m] ^ arr[i]
	count = 0
	while xor & xor - 1:
		count += 1
		xor = xor & xor - 1
	if count + 1 <= k:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
x = []
for i in range(0, m + 1):
	x.append(int(input()))
fed = x[m]
friend = 0
for i in x[:m]:
	xor = fed ^ i
	op = 1
	count = 0
	for j in range(1, n + 1):
		if xor & op:
			count = count + 1
		op = op << 1
	if count <= k:
		friend = friend + 1
print(friend)


def countOnes(n):
	count = 0
	while n:
		n &= n - 1
		count += 1
	return count
(n, m, k) = map(int, input().split())
list_army = []
count = 0
for i in range(m + 1):
	x = int(input())
	list_army.append(x)
for i in range(m):
	res = list_army[i] ^ list_army[m]
	if countOnes(res) <= k:
		count += 1
print(count)


def intToBin(num: int):
	return '{0:b}'.format(num)

def inpNum():
	return int(input())

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

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

def inpMatrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]
(n, m, k) = inpNums()
players = [int(input()) for _ in range(m)]
f = int(input())
friends = 0
for p in players:
	if intToBin(f ^ p).count('1') <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
army = []
for _ in range(m + 1):
	army.append(int(input()))

def solve(A, B):
	count = 0
	for i in range(0, 32):
		if A >> i & 1 != B >> i & 1:
			count = count + 1
	return count
ans = 0
for i in range(m):
	if solve(army[i], army[-1]) <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = []
schet = 0
for i in range(m + 1):
	z = int(input())
	a.append(z)
for i in range(m):
	x = a[i] ^ a[m]
	x = str(bin(x))
	if str(x).count('1') <= k:
		schet += 1
print(schet)


(n, m, k) = [int(i) for i in input().split()]
lst = [bin(int(input()))[2:] for i in range(m + 1)]
lst = [(n - len(lst[i])) * '0' + lst[i] for i in range(m + 1)]
friendsNum = 0
for i in range(m):
	diff = 0
	for j in range(n):
		if lst[-1][j] != lst[i][j]:
			diff += 1
			if diff > k:
				break
	else:
		friendsNum += 1
print(friendsNum)


from sys import stdin, stdout
from functools import reduce

def ii():
	return int(stdin.readline())

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

def li():
	return list(mi())

def si():
	return stdin.readline()

def bits(a, b):
	i = 0
	c = a ^ b
	while c > 0:
		c = c & c - 1
		i += 1
	return i
(n, m, k) = mi()
l1 = []
for j in range(m):
	l1.append(ii())
fedor = ii()
ans = 0
for i in l1:
	if bits(fedor, i) <= k:
		ans += 1
print(ans)


def to_binary(n, size):
	s = []
	while 1:
		r = n % 2
		n = n // 2
		s.append(r)
		if n == 0:
			break
	while len(s) < size:
		s.append(0)
	s.reverse()
	return s
(n, m, k) = map(int, input().split())
a = [0] * (m + 1)
for i in range(m + 1):
	a[i] = int(input())
fedor = [0] * n
fedor = to_binary(a[m], n)
cnt = 0
for i in range(m):
	x = to_binary(a[i], n)
	sum = 0
	for j in range(n):
		if fedor[j] != x[j]:
			sum += 1
	if sum <= k:
		cnt += 1
print(cnt)


from operator import xor
(n, m, k) = map(int, input().split(' '))
c = []
counts = 0
for i in range(m + 1):
	d = int(input())
	c.append(d)
e = c[-1]
for j in range(m):
	f = bin(xor(c[j], e))
	g = f.count('1')
	if g <= k:
		counts = counts + 1
print(counts)


def countSetBits(num):
	binary = bin(num)
	setBits = [ones for ones in binary[2:] if ones == '1']
	return len(setBits)
[n, m, k] = [int(x) for x in input().split()]
nos = []
for case in range(m + 1):
	nos.append(int(input()))
count = 0
for case in range(m):
	if countSetBits(nos[m] ^ nos[case]) > k:
		continue
	else:
		count += 1
print(count)


def solve(A, B):
	count = 0
	for i in range(0, 32):
		if A >> i & 1 != B >> i & 1:
			count = count + 1
	return count
(n, m, k) = [int(x) for x in input().split(' ')]
l = []
f = 0
for i in range(m + 1):
	l.append(int(input()))
for i in range(m):
	d = solve(l[m], l[i])
	if d <= k:
		f += 1
print(f)


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(N, M, K) = map(int, input().split())
A = []
for i in range(M + 1):
	A.append(int(input()))
ans = 0
for i in range(M):
	v = A[i] ^ A[M]
	k = 0
	while v > 0:
		if v & 1:
			k += 1
		v >>= 1
	if k <= K:
		ans += 1
print(ans)


def main():
	(n, m, k) = map(int, input().split())
	armies = []
	for i in range(m + 1):
		armies.append(int(input()))
	fedor = armies[-1]
	cnt = 0
	for army in armies[:-1]:
		if bin(fedor ^ army).count('1') <= k:
			cnt += 1
	print(cnt)
	return
main()


(n, m, k) = [int(x) for x in input().split()]
players = []
for i in range(m + 1):
	d = int(input())
	d = bin(d)[2:].zfill(n + 1)
	players.append(d)
a = players[m]
c = 0
for i in range(m):
	z = 0
	for j in range(n + 1):
		if a[j] == '1' or players[i][j] == '1':
			if not a[j] == players[i][j]:
				z = z + 1
	if z <= k:
		c = c + 1
print(c)


(n, m, k) = map(int, input().split())
soldiers = []
for _ in range(m):
	cur_sold = format(int(input()), '#022b')[2:]
	soldiers.append(cur_sold)
vasya = format(int(input()), '#022b')[2:]
ans = 0
for s in soldiers:
	ans += sum((a != b for (a, b) in zip(vasya, s))) <= k
print(ans)


(n, m, k) = [int(x) for x in input().split()]
if m == 0:
	print(0)
else:
	dp = [int(input()) for _ in range(m + 1)]
	ans = 0
	for i in dp:
		if bin(i ^ dp[m]).count('1') <= k:
			ans += 1
	print(ans - 1)


def f(n, a, b):
	cnt = 0
	now = 1
	for i in range(n):
		if a & now == b & now:
			cnt += 1
		now *= 2
	return cnt
(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
ans = 0
for i in range(m):
	if f(n, a[i], a[m]) >= n - k:
		ans += 1
print(ans)


def FedorAndNewGame(n, m, k, army):
	friendCount = 0
	i = 0
	while i < m:
		result = army[m] ^ army[i]
		binary = bin(result)
		setBits = [ones for ones in binary[2:] if ones == '1']
		if len(setBits) <= k:
			friendCount += 1
		i += 1
	return friendCount
(n, m, k) = [int(x) for x in input().split()]
i = 0
army = []
while i <= m:
	army.append(int(input()))
	i += 1
print(FedorAndNewGame(n, m, k, army))


def d2b(n):
	return '{0:b}'.format(int(n))
(n, m, k) = list(map(int, input().split(' ')))
army = []
for i in range(1, m + 2):
	army.append([int(input())])
ct = 0
for j in range(m):
	if d2b(army[j][0] ^ army[m][0]).count('1') <= k:
		ct += 1
print(ct)


(n, m, k) = map(int, input().split())
arr = [int(input()) for x in range(m + 1)]
ans = 0
for item in arr[:-1]:
	c = 0
	for i in range(n):
		mask = 1 << i
		if mask & item != mask & arr[-1]:
			c += 1
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
arr = []
for i in range(m):
	arr.append(int(input()))
f = int(input())
ans = 0
for a in arr:
	x = bin(a ^ f)
	if x.count('1') <= k:
		ans += 1
print(ans)


import sys
I = sys.stdin.readline

def solve():
	(n, m, k) = map(int, I().split())
	army = []
	ans = 0
	for i in range(m + 1):
		army.append(int(I()))
	j = army[-1]
	for i in range(m):
		x = army[i] ^ j
		d = bin(x).count('1')
		if d <= k:
			ans += 1
	print(ans)
solve()


t = input()
temp = t.split()
n = int(temp[0])
m = int(temp[1])
k = int(temp[2])
armyList = []
friendCount = 0
for i in range(m + 1):
	s = input()
	integer = int(s)
	armyList.append(integer)

def compareBits(a, b):
	bitCount = 0
	for i in range(0, 32):
		if a >> i & 1 != b >> i & 1:
			bitCount += 1
	return bitCount
for i in range(m):
	bitCount = compareBits(armyList[i], armyList[m])
	if bitCount <= k:
		friendCount += 1
print(friendCount)


(n, m, k) = map(int, input().split())
a = []
z = 0
d = ''
for i in range(m + 1):
	x = int(input())
	a.append(x)
f = a[len(a) - 1]
for i in range(len(a) - 1):
	s = bin(a[i] ^ f)
	if s.count('1') <= k:
		z = z + 1
print(z)


(n, m, k) = input().split()

def countSetBits(n):
	count = 0
	while n:
		n &= n - 1
		count += 1
	return count
m = int(m) + 1
k = int(k)
list1 = []
for i in range(m):
	temp = int(input())
	list1.append(temp)
friends = 0
for i in range(len(list1) - 1):
	xor = list1[i] ^ list1[-1]
	csb = countSetBits(xor)
	if csb <= k:
		friends += 1
print(friends)


t = 1
while t > 0:
	t = t - 1
	[n, m, k] = [int(x) for x in input().split()]
	ans = 0
	l = []
	for i in range(0, m + 1):
		x = int(input())
		l.append(x)
	for i in range(0, m):
		f = 0
		for j in range(0, n):
			if l[i] >> j & 1 != l[m] >> j & 1:
				f = f + 1
		if f <= k:
			ans = ans + 1
	print(ans)


from sys import stdin, stderr

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

def print_err(*args, **kwargs):
	print(*args, file=stderr, **kwargs)

def popcount(v):
	c = 0
	while v > 0:
		if v % 2 == 1:
			c += 1
		v //= 2
	return c

def run():
	(n, m, k) = readInts()
	armies = []
	for _ in range(m):
		(army,) = readInts()
		armies.append(army)
	(fedor,) = readInts()
	ok = 0
	for _ in range(m):
		v = fedor ^ armies.pop()
		if popcount(v) <= k:
			ok += 1
	print(ok)
run()


(n, m, k) = map(int, input().split())
line = []
count = 0
for i in range(m + 1):
	line.append(int(input()))
for i in range(m):
	if bin(line[i] ^ line[m]).count('1') <= k:
		count += 1
print(count)


(n, m, r) = list(map(int, input().split()))
mas = []
result = 0
for i in range(m + 1):
	x = int(input())
	mas.append(x)
for j in range(m):
	Colvo = 0
	Res = mas[-1] ^ mas[j]
	while Res > 0:
		Colvo += Res % 2
		Res //= 2
	if Colvo <= r:
		result += 1
print(result)


def dec_to_bin(x):
	return bin(x)[2:]

def compare(x, y):
	charX = list(dec_to_bin(x))
	charY = list(dec_to_bin(y))
	differ = 0
	while len(charX) < len(charY):
		charX.insert(0, '0')
	while len(charY) < len(charX):
		charY.insert(0, '0')
	for i in range(0, len(charX)):
		if charX[i] != charY[i]:
			differ += 1
	return differ
(n, m, k) = [int(x) for x in input().split()]
numbers = []
for i in range(0, m + 1):
	numbers.append(int(input()))
res = 0
for i in range(0, m):
	if compare(numbers[i], numbers[m]) <= k:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(format(int(input()), 'b')[::-1])
t = a.pop()
l = len(t)
f = 0
for i in a:
	c = 0
	x = 0
	for j in range(min(l, len(i))):
		if t[j] != i[j]:
			c += 1
		if c > k:
			x = 1
			break
	if len(i) < l:
		c += t[len(i):].count('1')
	if len(i) > l:
		c += i[l:].count('1')
	if c > k:
		x = 1
	if x != 1:
		f += 1
print(f)


(n, m, k) = map(int, input().split())
b = []
for _ in range(m + 1):
	b.append(int(input()))

def diff(n):
	count = 0
	while n > 0:
		if n % 2 != 0:
			count += 1
		n = int(n / 2)
	return count
ans = 0
for i in range(0, m):
	if diff(b[i] ^ b[m]) <= k:
		ans += 1
print(ans)


(n, m, k) = [int(x) for x in input().split(' ')]
binary_army = []
count = 0
for i in range(m + 1):
	player_army = int(input())
	binary_army.append(player_army)
for a in range(m + 1):
	binary_army[a] = bin(binary_army[a] ^ binary_army[-1])
for b in binary_army[:-1]:
	if str(b)[2:].count('1') <= k:
		count += 1
print(count)


def main():
	ans = 0
	(n, m, k) = [int(i) for i in input().split()]
	x = []
	for i in range(m + 1):
		x.append(int(input()))
	f = x[-1]
	for i in range(m):
		temp = bin(x[i] ^ f)
		if temp.count('1') <= k:
			ans += 1
	print(ans)
main()


(n, m, k) = input().split()
(n, m, k) = (int(n), int(m), int(k))
Sum = 0
A = []
for i in range(0, m + 1):
	a = int(input())
	a = bin(a).replace('0b', '')
	if len(a) < n:
		for x in range(0, n - len(a)):
			a = '0' + a
	A.append(str(a))
for j in range(0, m):
	count = 0
	for l in range(0, n):
		if A[-1][l] != A[j][l]:
			count = count + 1
	if count <= k:
		Sum = Sum + 1
print(Sum)


def format(a):
	a = bin(int(a)).split('b')[1]
	a = '0' * (n - len(a)) + a
	return a
(n, m, k) = map(int, input().split())
l = []
c = s = 0
for _ in range(m):
	a = format(input())
	l.append(a)
fed = format(input())
for i in l:
	c = 0
	for j in range(n):
		if fed[j] != i[j]:
			c += 1
			if c > k:
				break
	if c <= k:
		s += 1
print(s)


def dist(s1, s2):
	d = 0
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			d += 1
	return d
(n, m, k) = list(map(int, input().split()))
friends = []
maxv = 0
for i in range(m + 1):
	temp = int(input())
	maxv = max(maxv, temp)
	if maxv == temp:
		maxi = i
	friends.append(bin(temp)[2:])
ff = ['0' * (len(friends[maxi]) - len(e)) + e for e in friends]
temp = ff.pop()
cont = 0
for e in ff:
	if dist(e, temp) <= k:
		cont += 1
print(cont)


def main():
	(n, m, k) = map(int, input().split(' '))
	x = []
	for _ in range(m + 1):
		x.append(int(input()))
	friendsCount = 0
	for i in range(m):
		if bin(x[m] ^ x[i]).count('1') <= k:
			friendsCount += 1
	print(friendsCount)
main()


(n, m, k) = map(int, input().split())
q = []
for j in range(m):
	x = int(input())
	bits = [0] * 21
	i = 20
	while i >= 0:
		if x // 2 ** i >= 1:
			x = x % 2 ** i
			bits[i] = 1
		i -= 1
	q.append(bits)
x = int(input())
bits = [0] * 21
i = 20
while i >= 0:
	if x // 2 ** i >= 1:
		x = x % 2 ** i
		bits[i] = 1
	i -= 1
c = 0
l = []
s = 0
for j in range(m):
	for i in range(21):
		if bits[i] != q[j][i]:
			c += 1
	if c <= k:
		s += 1
	c = 0
print(s)


a = input().split()
c = []
kmdlg = 0
for i in range(0, int(a[1]) + 1):
	b = int(input())
	c.append(int(b))
m = max(c)
friends = 0

def binary(aa):
	bb = ''
	while aa > 1:
		bb = bb + str(aa % 2)
		aa = aa // 2
	bb = bb + str(aa % 2)
	bb = bb[::-1]
	return list(bb)
poo = binary(m)
poo = len(poo)

def bits(fg, kg):
	global friends
	binn = binary(fg)
	binnn = binary(kg)
	if len(binn) < poo:
		pd = poo - len(binn)
		binn = ['0'] * pd + binn
	if len(binnn) < poo:
		pd = poo - len(binnn)
		binnn = ['0'] * pd + binnn
	count = 0
	for i in range(0, poo):
		if binn[i] != binnn[i]:
			count = count + 1
	if count <= int(a[2]):
		friends = friends + 1
for i in range(0, int(a[1])):
	bits(c[-1], c[i])
print(friends)


(n, m, k) = map(int, input().split(' '))
l = list()
for i in range(m):
	l.append(int(input()))
m1 = 2 ** (n + 1) | int(input())
for i in l:
	j = -1
	i = 2 ** (n + 1) | i
	kcount = 0
	for j in range(n + 1):
		j = -j
		if not bin(i)[j] == bin(m1)[j]:
			kcount += 1
		if kcount > k:
			m -= 1
			break
print(m)


from sys import stdin
hat = stdin.readlines()
(n, m, k) = map(int, hat[0].split())
ans = []
count = 0

def popcount(x):
	b = 0
	while x:
		if x & 1:
			b += 1
		x >>= 1
	return b
for i in range(m + 1):
	ans.append(int(hat[1 + i]))
for i in range(m):
	if popcount(ans[-1] ^ ans[i]) <= k:
		count += 1
print(count)


list = []
friends = 0
(n, m, k) = map(int, input().split())
m += 1
while m > 0:
	temp = int(input())
	list.append(temp)
	m -= 1
lastPlayer = list[len(list) - 1]
for i in range(0, len(list) - 1):
	result = list[i] ^ lastPlayer
	if bin(result).count('1') <= k:
		friends += 1
print(friends)


def countBit(n):
	c = 0
	while n > 0:
		n = n & n - 1
		c = c + 1
	return c
isDebug = False
(n, m, k) = [int(x) for x in input().split()]
s = []
for i in range(0, m + 1):
	x = int(input())
	s.append(x)
print(f's={s}') if isDebug else ''
p = s[m]
c = 0
for i in range(0, m):
	a = s[i]
	tb = countBit(a ^ p)
	print(f'p={p}, a={a}, a^p={a ^ p} tb={tb}') if isDebug else ''
	if tb <= k:
		c = c + 1
print(f'{c}')


(n, m, k) = map(int, input().split())
l = [int(input()) for i in range(m)]
f = int(input())
ans = 0
for i in range(m):
	if bin(l[i] ^ f).count('1') <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	l.append(int(input()))
res = 0
for j in range(len(l) - 1):
	if bin(l[j] ^ l[-1]).count('1') <= k:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
(x, c) = ([int(input()) for i in range(m + 1)], 0)
for f in range(m):
	s = 0
	for i in range(25):
		s += 1 if 1 & x[f] >> i != 1 & x[m] >> i else 0
	if s <= k:
		c += 1
print(c)


def binary(n):
	s = ''
	while n > 0:
		s += str(n % 2)
		n = int(n / 2)
	return s[::-1]

def distinct(n, l, r):
	l = '0' * (n - len(l)) + l
	r = '0' * (n - len(r)) + r
	cnt = 0
	for i in range(n):
		if l[i] != r[i]:
			cnt += 1
	return cnt
(n, m, k) = map(int, input().split())
list = []
for i in range(m + 1):
	list.append(int(input()))
ans = 0
s = binary(list[m])
for i in range(0, m):
	if distinct(n, s, binary(list[i])) <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
x = [int(input()) for _ in range(m + 1)]
ans = 0
for xi in x[:-1]:
	if bin(xi ^ x[-1]).count('1') <= k:
		ans += 1
print(ans)


import sys
f = sys.stdin.readline
(n, m, k) = map(int, f().strip().split())
pl = []
for i in range(m):
	x = int(f().strip())
	pl.append(x)
fed = int(f().strip())

def getCount(fi, se):
	c = 0
	while fi > 0 or se > 0:
		if fi & 1 != se & 1:
			c += 1
		elif fi == 0 and se & 1 == 1:
			c += 1
		elif se == 0 and fi & 1 == 1:
			c += 1
		fi >>= 1
		se >>= 1
	return c
ans = 0
for p in pl:
	x = getCount(fed, p)
	if x <= k:
		ans += 1
print(ans)


import math
(n, m, k) = list(map(int, input().split()))
lst = [0] * m
res = [0] * m
ans = 0
otvet = 0
for i in range(m):
	lst[i] = int(input())
fed = int(input())
for i in range(m):
	res[i] = lst[i] ^ fed
	res[i] = bin(res[i])[2:]
	ans = 0
	for j in range(len(res[i])):
		if res[i][j] == '1':
			ans += 1
	if ans <= k:
		otvet += 1
print(otvet)


(n, m, k) = [int(a) for a in input().split()]
army = []
for i in range(m):
	army.append(int(input()))

def hammingdistance(one, two):
	if one == two:
		return 0
	if one & 1 == two & 1:
		return hammingdistance(one >> 1, two >> 1)
	else:
		return 1 + hammingdistance(one >> 1, two >> 1)
fedor = int(input())
friends = 0
for i in range(m):
	if hammingdistance(fedor, army[i]) <= k:
		friends += 1
print(friends)


def diff(a, b, k, n):
	cnt = 0
	for i in range(n):
		aa = bool(a & 1 << i)
		bb = bool(b & 1 << i)
		cnt += aa != bb
	return cnt <= k
(n, m, k) = map(int, input().split())
a = [int(input()) for i in range(m + 1)]
ans = 0
for i in range(m):
	ans += diff(a[i], a[-1], k, n)
print(ans)


def diff(a, b):
	length = 0
	d = 0
	if len(a) > len(b):
		b = '0' * (len(a) - len(b)) + b
		length = len(a)
	else:
		a = '0' * (len(b) - len(a)) + a
		length = len(b)
	for i in range(0, length):
		if a[i] != b[i]:
			d = d + 1
	return d
[n, m, k] = [int(x) for x in input().split()]
friends = []
for i in range(0, m):
	friends.append('{0:b}'.format(int(input())))
fedor = '{0:b}'.format(int(input()))
ans = 0
for i in range(0, m):
	mydiff = diff(fedor, friends[i])
	if mydiff <= k:
		ans = ans + 1
print(ans)


(n, m, k) = map(int, input().split())
l = [int(input()) for i in range(m + 1)]
ans = 0
for i in range(m):
	x = l[i] ^ l[-1]
	cnt = 0
	while x > 0:
		x = x & x - 1
		cnt += 1
	if cnt <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
other_players = []
potential_freinds = 0
for i in range(m + 1):
	player = int(input())
	player = bin(player).replace('0b', '')
	player = '0' * (n - len(player)) + player
	other_players.append(player)
for i in range(m):
	differences = 0
	for j in range(n):
		if other_players[-1][j] != other_players[i][j]:
			differences += 1
	if differences <= k:
		potential_freinds += 1
print(potential_freinds)


(n, m, k) = list(map(int, input().rstrip().split()))
army = []
for _ in range(m + 1):
	army += [int(input())]

def decimalToBinary(x):
	return str(bin(x)[2:].zfill(n))
fedor = str(bin(army[m])[2:].zfill(n))
count = 0
for i in range(m):
	x = decimalToBinary(army[i])
	t = 0
	for j in range(n):
		if x[j] == fedor[j]:
			t += 1
	if n - t <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
l1 = []
for i in range(m):
	l1.append(int(input()))
y = int(input())
ans = 0
for item in l1:
	if bin(y ^ item).count('1') <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
fed = int(input())
ans = 0
for j in range(m):
	k1 = 0
	for i in range(n):
		if a[j] >> i & 1 != fed >> i & 1:
			k1 += 1
	if k1 <= k:
		ans += 1
print(ans)


num = list(map(int, input().split()))
(n, m, k) = (num[0], num[1], num[2])
players = []
for _ in range(m):
	players.append(int(input()))
fed = int(input())
fedtr = format(fed, '#0' + str(n + 2) + 'b')[2:]
total = 0
for i in players:
	tempstr = format(i, '#0' + str(n + 2) + 'b')[2:]
	u = zip(fedtr, tempstr)
	count = 0
	for (i, j) in u:
		if i != j:
			count = count + 1
	if count <= k:
		total = total + 1
print(total)


(n, m, k) = [int(x) for x in input().split()]
arr = []
o = 0
for i in range(m):
	arr.append(int(input()))
f = int(input())
f2 = []
for i in range(n - 1, -1, -1):
	if 2 ** i <= f:
		f -= 2 ** i
		f2.append(True)
	else:
		f2.append(False)
for i in arr:
	z = 0
	for j in range(n - 1, -1, -1):
		if 2 ** j <= i:
			i -= 2 ** j
			if not f2[n - 1 - j]:
				z += 1
		elif f2[n - j - 1]:
			z += 1
	if z <= k:
		o += 1
print(o)


from math import *
(n, m, k) = map(int, input().split())
L = [int(input()) for _ in range(m + 1)]

def binaire(n):
	if n == 0:
		return '0'
	elif n == 1:
		return '1'
	else:
		return str(n % 2) + binaire(n // 2)
B = [binaire(L[i]) for i in range(m + 1)]
B = [B[i] + '0' * (n - len(B[i])) for i in range(m + 1)]
R = [0 for _ in range(m)]
for i in range(m):
	for t in range(n):
		R[i] += B[m][t] != B[i][t]
F = [R[i] <= k for i in range(m)]
print(sum(F))


(n, m, k) = [int(i) for i in input().strip().split()]
a = []
for i in range(m):
	a.append(int(input().strip()))
x = int(input().strip())
ans = 0
for i in a:
	if bin(i ^ x).count('1') <= k:
		ans = ans + 1
print(ans)


(n, m, x) = list(map(int, input().split()))
a = []
for i in range(m + 1):
	k = int(input())
	a.append(k)
k = bin(a[-1])[2:]
(q, l) = (len(k), 0)
for i in range(m):
	t = bin(a[i])[2:]
	b = 0
	(w, r) = (len(t), k)
	if q > w:
		t = '0' * (q - w) + t
	if w > q:
		r = '0' * (w - q) + r
	for j in range(max(q, w)):
		if t[j] != r[j]:
			b = b + 1
		if b > x:
			break
	if b <= x:
		l = l + 1
print(l)


(n, m, k) = input().split()
army_lst = list()
friends = 0
for i in range(int(m) + 1):
	army = int(input())
	army_lst.append(army)
for i in range(len(army_lst) - 1):
	k_bits = 0
	XOR = army_lst[i] ^ army_lst[int(m)]
	XOR = list(bin(XOR))
	k_bits = XOR.count('1')
	if k_bits <= int(k):
		friends += 1
print(friends)


def solve(players, k, f):
	res = 0
	for i in players:
		diff = f ^ i
		bitcount = 0
		while diff:
			bitcount += diff & 1
			diff = diff >> 1
		res += bitcount <= k
	return res
parse = lambda st: map(int, st.split())
(n, m, k) = map(int, input().split())
res = solve([int(input()) for _ in range(m)], k, int(input()))
print(res)


def countSetBits(num):
	binary = bin(num)
	setBits = [ones for ones in binary[2:] if ones == '1']
	return len(setBits)
(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
m = m + 1
i = 1
p = []
while i <= m:
	y = int(input())
	p.append(y)
	i = i + 1
o = p[::-1]
count = 0
ele = o[0]
i = 1
while i < m:
	r = o[i]
	diff = ele ^ r
	rp = countSetBits(diff)
	if rp <= k:
		count = count + 1
	i = i + 1
print(count)


import sys
import math
(n, m, k) = map(int, input().split())
x = [int(input()) for s in range(m)]
y = int(input())
ans = 0
for a in x:
	if bin(a ^ y).count('1') <= k:
		ans += 1
print(ans)


inp = input()
inp = inp.split(' ')
n = int(inp[0])
m = int(inp[1])
k = int(inp[2])
count = 0
bin_ints = []
for i in range(m):
	bin_ints.append(int(input()))
fedor = int(input())
print(len(list(filter(lambda e: bin(e ^ fedor).count('1') <= k, bin_ints))))


(n, m, k) = list(map(int, input().split()))
a = []
for i in range(m + 1):
	y = int(input())
	a.append(y)
t = bin(a[-1])[2:]
maini = 0
for i in range(len(a) - 1):
	y = bin(a[i])[2:]
	if len(y) > len(t):
		pepsi = '0' * (len(y) - len(t)) + t
		pepso = y
	elif len(t) > len(y):
		pepsi = '0' * (len(t) - len(y)) + y
		pepso = t
	else:
		pepsi = t
		pepso = y
	count = 0
	for j in range(len(pepsi)):
		if pepsi[j] != pepso[j]:
			count += 1
			if count > k:
				break
	if count <= k:
		maini += 1
print(maini)


def get_diff(a, f):
	s = 0
	while a != 0 or f != 0:
		a_b = a % 2
		f_b = f % 2
		a //= 2
		f //= 2
		if a_b != f_b:
			s += 1
	return s
(n, m, k) = map(int, input().split())
l = list()
for _ in range(m):
	l.append(int(input()))
f = int(input())
s = 0
for i in l:
	s += 1 if get_diff(i, f) <= k else 0
print(s)


def are_friends(y, z, k):
	ndiff = 0
	while y > 0 or z > 0:
		if y % 2 == z % 2:
			pass
		else:
			ndiff += 1
		y //= 2
		z //= 2
	if ndiff > k:
		return False
	else:
		return True
(n, m, k) = map(int, input().split())
x = []
for i in range(0, m + 1):
	x.append(int(input()))
nfriends = 0
for i in range(0, m):
	if are_friends(x[i], x[m], k):
		nfriends += 1
print(nfriends)


from sys import stdin, stdout

def compare(f, s, k):
	xor = f ^ s
	temp = 0
	while xor != 0:
		temp += xor & 1
		xor >>= 1
	return 1 if temp <= k else 0
(n, m, k) = map(int, stdin.readline().split())
my_lst = []
for i in range(m):
	my_lst.append(int(stdin.readline()))
fedor = int(stdin.readline())
ans = 0
for i in my_lst:
	ans += compare(fedor, i, k)
print(ans)


(n, m, k) = map(int, input().split())
x = []
for i in range(m):
	x0 = int(input())
	x.append(x0)
fedor = int(input())
count = 0

def oneCount(arg):
	cnt = 0
	while arg != 0:
		if arg & 1 == 1:
			cnt += 1
		arg >>= 1
	return cnt
for i in range(m):
	mismatch = fedor ^ x[i]
	if oneCount(mismatch) <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
players = [int(input()) for i in range(m)]
fedor = int(input())
c = 0
for p in players:
	if bin(p ^ fedor).count('1') <= k:
		c += 1
print(c)


(n, m, k) = [int(x) for x in input().split()]
(*a, b) = [int(input()) for _ in range(m + 1)]
print(sum((bin(x ^ b).count('1') <= k for x in a)))


(n, m, k) = map(int, input().split())
b = []
cnt = 0
for _ in range(m + 1):
	b.append(int(input()))
for i in range(m):
	b[i] = bin(b[i] ^ b[-1])
	if b[i].count('1') <= k:
		cnt += 1
print(cnt)


def set_bits(n, k):
	c = 0
	while n > 0:
		n = n & n - 1
		c += 1
	if c <= k:
		return True
	return False
(n, m, k) = map(int, input().split())
l = []
for i in range(m):
	l.append(int(input()))
fedor_army = int(input())
ans = 0
for i in l:
	temp = fedor_army ^ i
	if set_bits(temp, k):
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
arr = []
for i in range(0, m + 1):
	arr.append(int(input()))
req = arr[m]
count = 0
for i in range(0, m):
	current = arr[i]
	a = list(map(int, str(bin(req ^ current))[2:]))
	if sum(a) <= k:
		count += 1
print(count)


def same(s1, s2):
	k = 0
	for i in range(n):
		if s1[i] != s2[i]:
			k += 1
	return k
(n, m, k) = map(int, input().split())
kol = 0
a = []
for i in range(m + 1):
	a.append(bin(int(input()))[2:].rjust(n, '0'))
for i in range(m):
	if same(a[i], a[-1]) <= k:
		kol += 1
print(kol)


import math

def d(a, b):
	return bin(a ^ b).count('1')
(n, m, k) = map(int, input().split())
a = [0] * m
for i in range(m):
	a[i] = int(input())
fe = int(input())
c = 0
for x in a:
	if d(x, fe) <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split(' '))
p = []
for i in range(m + 1):
	p = p + [int(input())]
f = 0
i = 0
j = 0

def onedig(a):
	z = 0
	for t in a:
		if t == '1':
			z += 1
	return z
fedor = p[-1]
while i < m:
	if onedig(bin(fedor ^ p[i])) <= k:
		f += 1
	i += 1
print(f)


def Fedor(l, k):
	count = 0
	for i in range(len(l) - 1):
		if sum((int(x) for x in list('{0:b}'.format(abs(l[i] ^ l[len(l) - 1]))))) <= k:
			count += 1
	print(count)
d = input()
l = []
n = int(d.split()[0])
m = int(d.split()[1])
k = int(d.split()[2])
for i in range(m + 1):
	d = input()
	l.append(int(d))
Fedor(l, k)


(n, m, k) = map(int, input().split())
other = []
fr = 0
for i in range(m):
	x = int(input())
	st = bin(x)[2:]
	tt = (n - len(st)) * '0' + st
	other.append(tt)
f = bin(int(input()))[2:]
fo = (n - len(f)) * '0' + f
for w in other:
	ut = []
	for j in range(n):
		she = abs(int(w[j]) - int(fo[j]))
		ut.append(she)
	ss = sum(ut)
	if ss <= k:
		fr += 1
print(fr)


(n, m, k) = map(int, input().split())
a = []
b = []
d = 0
e = 0
for i in range(m + 1):
	x = int(input())
	a.append(x)
for i in range(m):
	b.append(bin(a[-1] ^ a[i]).replace('0b', ''))
for i in b:
	c = list(i)
	for j in range(len(c)):
		if c[j] == '1':
			d += 1
	if d <= k:
		e += 1
	d = 0
print(e)


def byte_v(a, n):
	ans = []
	while a != 0:
		ans.append(a % 2)
		a //= 2
	ans.reverse()
	ans = (n - len(ans)) * [0] + ans
	return ans
(n, m, k) = map(int, input().split())
players = []
for i in range(m + 1):
	curr_army = int(input())
	players.append(list(byte_v(curr_army, n)))
phill = players[-1]
ans = 0
for i in range(m):
	curr = 0
	for j in range(n):
		if phill[j] != players[i][j]:
			curr += 1
	if curr <= k:
		ans += 1
print(ans)


(n, m, k) = [int(i) for i in input().split()]
x = []
for i in range(m):
	x = x + [bin(int(input()))[2:]]
cnt = 0
y = bin(int(input()))[2:]
y = '0' * (n - len(y)) + y
for i in range(m):
	f = x[i]
	a = '0' * (n - len(f)) + f
	diff = 0
	for j in range(len(a)):
		if a[j] != y[j]:
			diff += 1
	if diff <= k:
		cnt += 1
print(cnt)


(n, m, k) = map(int, input().split())
L = []
for i in range(m):
	L.append(int(input()))
fedor = int(input())
num = 0
for i in L:
	if bin(i ^ fedor).count('1') <= k:
		num += 1
print(num)


(n, m, k) = map(int, input().split())
arr = []
for i in range(m):
	arr.append(int(input()))
t = int(input())
res = 0
for i in arr:
	x = bin(i ^ t)
	if x.count('1') <= k:
		res += 1
print(res)


(n, m, k) = [int(x) for x in input().split()]
a = []
for i in range(m + 1):
	a.append(int(input()))
p = a[m]
a = a[:-1]
s = sum([1 if bin(x ^ p).count('1') <= k else 0 for x in a])
print(s)


(n, m, k) = map(int, input().split())

def get_diffs(a, b):
	if a < b:
		(a, b) = (b, a)
	diffs = 0
	while b > 0:
		if b & 1 and (not a & 1) or (not b & 1 and a & 1):
			diffs += 1
		a >>= 1
		b >>= 1
	while a > 0:
		if a & 1:
			diffs += 1
		a >>= 1
	return diffs
teams = []
for i in range(m + 1):
	teams.append(int(input()))
ans = 0
for i in range(m):
	diffs = get_diffs(teams[m], teams[i])
	if diffs <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a += [int(input())]
res = int(input())
ans = 0
for i in range(m):
	val = res ^ a[i]
	c = 0
	while val != 0:
		val = val & val - 1
		c += 1
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
x = [int(input()) for i in range(m)]
F = int(input())
ans = 0
for el in x:
	if bin(el ^ F).count('1') <= k:
		ans += 1
print(ans)


def diff(a, b):
	while len(a) < len(b):
		a = '0' + a
	while len(b) < len(a):
		b = '0' + b
	ret = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			ret += 1
	return ret
(n, m, k) = map(int, input().split())
L = []
for i in range(m):
	x = int(input())
	L.append(bin(x)[2:])
s = bin(int(input()))[2:]
ans = 0
for i in range(m):
	z = diff(L[i], s)
	if z <= k:
		ans += 1
print(ans)


def xor(a, b):
	return bin(a ^ b).count('1')
(n, m, k) = map(int, input().split())
l = []
for i in range(m):
	l.append(int(input()))
fedor = int(input())
counter = 0
for i in l:
	if xor(fedor, i) <= k:
		counter += 1
print(counter)


(n, m, k) = map(int, input().rstrip().split())
a = []
for _ in range(m):
	x = int(input())
	a.append(x)
c = 0
x = int(input())
for i in range(len(a)):
	z = list(bin(a[i] ^ x)[2:]).count('1')
	if z <= k:
		c += 1
print(c)


(n, m, k) = [int(x) for x in input().split()]
armies = [int(input()) for x in range(m + 1)]
result = 0
for i in range(m):
	aux = armies[-1] ^ armies[i]
	if bin(aux).count('1') <= k:
		result += 1
print(result)


(n, m, k) = [int(x) for x in input().split()]
players = []
for i in range(m):
	players.append(int(input()))
f = int(input())
ans = 0
for x in players:
	x ^= f
	cnt = 0
	while x:
		cnt += 1
		x &= x - 1
	if cnt <= k:
		ans += 1
print(ans)


import sys
input = sys.stdin.read()
data = list(map(int, input.split()))
(n, m, k) = (data[0], data[1], data[2])
data = data[3:]
ans = 0
for it in data[0:len(data) - 1]:
	x = data[-1] ^ it
	s = bin(x)
	y = s.count('1')
	if y <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
t = []
mx = 0
c1 = 0
for i in range(m + 1):
	zahl = input()
	bit = bin(int(zahl))
	if len(bit) > mx:
		mx = len(bit)
	t.append(bit[2:])
pepe = t[-1][::-1]
pepe += str(0) * (mx - len(pepe))
lol = pepe[::-1]
for i in range(m):
	pepe = t[i][::-1]
	pepe += str(0) * (mx - len(pepe))
	pepe = pepe[::-1]
	j = 0
	ch = 0
	while ch <= k and j < mx:
		if pepe[j] != lol[j]:
			ch += 1
		j += 1
	if ch <= k:
		c1 += 1
print(c1)


import math

def check(temp):
	cnt = 0
	while temp:
		cnt = cnt + 1
		temp = temp & temp - 1
	return cnt
(n, m, k) = [int(x) for x in input().split()]
list = []
temp = 0
count = 0
for i in range(m + 1):
	list.append(int(input()))
for x in range(m):
	temp = list[m] ^ list[x]
	cct = check(temp)
	if cct <= k:
		count = count + 1
print(count)


(n, m, k) = [int(x) for x in input().split()]

def isfriend(x, y):
	ctr = 0
	x = x ^ y
	while x:
		ctr += x & 1
		x //= 2
	if ctr <= k:
		return 1
	return 0
ans = 0
x = []
for i in range(m + 1):
	x.append(int(input()))
f = x[-1]
for i in range(m):
	ans += isfriend(f, x[i])
print(ans)


(n, m, k) = [int(x) for x in input().split()]
arr = [int(input()) for i in range(m + 1)]

def calc(x):
	return bin(x ^ arr[-1]).count('1') <= k
print(sum(map(calc, arr[:-1])))


def bits_count(a):
	a = int(a)
	ans = 0
	while a > 0:
		ans += a & 1
		a >>= 1
	return ans
s = [eval(i) for i in input().split()]
a = []
ans = 0
for i in range(s[1] + 1):
	a.append(int(input()))
for i in range(s[1]):
	if bits_count(int(a[i] ^ a[s[1]])) <= s[2]:
		ans += 1
print(ans)


(n, m, k) = [int(x) for x in input().split()]

def check(a, b, k):
	return bin(a ^ b).count('1') <= k
armies = []
for _ in range(m):
	armies.append(int(input()))
fedor = int(input())
print(sum((check(fedor, a, k) for a in armies)))


def count_char(a, b):
	return sum([1 if a[i] != b[i] else 0 for i in range(len(a))])
(n, m, k) = map(int, input().split())
x = [bin(int(input()))[2:].rjust(n, '0') for i in range(m + 1)]
print(sum([1 if count_char(x[i], x[m]) <= k else 0 for i in range(m)]))


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(bin(int(input())))

def compare(a, b):
	a = a[2:]
	b = b[2:]
	if len(a) < len(b):
		a = '0' * (len(b) - len(a)) + a
	else:
		b = '0' * (len(a) - len(b)) + b
	ans = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			ans += 1
	return ans
ans = 0
for i in range(m):
	if compare(a[-1], a[i]) <= k:
		ans += 1
print(ans)


nmk = [int(x) for x in input().split()]
nums = []
for i in range(nmk[1] + 1):
	n = int(input())
	b = f'{n:b}'
	nums.append(n)
k = 0
for i in range(nmk[1]):
	y = nums[nmk[1]] ^ nums[i]
	c = 0
	y = f'{y:b}'
	for n in y:
		if n == '1':
			c += 1
	if c <= nmk[2]:
		k += 1
print(k)


import math
from itertools import combinations
from functools import reduce
(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	kval = bin(int(input()))[2:]
	if len(kval) < n:
		kval = '0' * (n - len(kval)) + kval
	l.append(kval)
final = 0
for i in range(0, m):
	ans = 0
	for j in range(n):
		if l[m][j] != l[i][j]:
			ans += 1
		if ans > k:
			break
	if ans <= k:
		final += 1
print(final)


nmk = list(map(int, input().split()[:3]))
armys = []
tmp = int(0)
fallies = int(0)
while tmp != nmk[1] + 1:
	armys.append(int(input()))
	tmp += 1
fedya = armys[-1]
armys.pop()
for army in armys:
	tmp = bin(fedya ^ army)
	tmp2 = tmp.count('1')
	if tmp2 <= nmk[2]:
		fallies += 1
print(fallies)


(n, m, k) = map(int, input().split())
l = []
for _ in range(m + 1):
	l.append(int(input()))
fredo = l.pop()
k1 = bin(fredo)[2:].zfill(n)
c = 0
res = 0
for i in l:
	k2 = bin(i)[2:].zfill(n)
	for i in range(n):
		if k1[i] != k2[i]:
			c += 1
	if c <= k:
		res += 1
	c = 0
print(res)


(n, m, k) = map(int, input().split())
A = []
B = '0000000000000000000000000000000000000000000000000000000000000000000000000'
S = 0
for i in range(m + 1):
	X = bin(int(input()))
	A.append(X[:2] + B[:25 - len(X)] + X[2:])
for i in range(m):
	D = 0
	for j in range(len(A[m])):
		if A[i][j] != A[m][j]:
			D += 1
	if D <= k:
		S += 1
print(S)


(n, m, k) = list(map(int, input().split()))
ms = [bin(int(input()))[2:] for i in range(m)]
f = bin(int(input()))[2:]
f = '0' * (n - len(f)) + f
ans = 0
p = 0
for i in range(len(ms)):
	ms[i] = '0' * (n - len(ms[i])) + ms[i]
	p = 0
	for j in range(len(ms[i])):
		if ms[i][j] != f[j]:
			p += 1
	if p <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = list()
for i in range(m + 1):
	a.append(bin(int(input())))
x = 0
for i in range(m):
	h = 0
	(j, q) = (len(a[m]) - 1, len(a[i]) - 1)
	while a[m][j] != 'b' and a[i][q] != 'b':
		if a[m][j] != a[i][q]:
			h += 1
		j -= 1
		q -= 1
		if a[m][j] == 'b' and a[i][q] != 'b':
			while a[i][q] != 'b':
				if a[i][q] == '1':
					h += 1
				q -= 1
		elif a[m][j] != 'b' and a[i][q] == 'b':
			while a[m][j] != 'b':
				if a[m][j] == '1':
					h += 1
				j -= 1
	if h <= k:
		x += 1
print(x)


from sys import *
from math import *

def main():
	(n, m, k) = [int(x) for x in input().split()]
	a = []
	ans = 0
	for i in range(m + 1):
		a.append(int(input()))
	for i in range(len(a) - 1):
		t = a[-1] ^ a[i]
		c = 0
		d = []
		while t > 0:
			c += t % 2
			t //= 2
		if c <= k:
			ans += 1
	print(ans)
main()


def setbits(n):
	count = 0
	while n > 0:
		if n % 2 == 1:
			count += 1
		n = n // 2
	return count
(n, m, k1) = map(int, input().split())
L = []
for i in range(m):
	k = int(input())
	L.append(k)
player = int(input())
ans = 0
for i in range(m):
	if setbits(L[i] ^ player) <= k1:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	a = int(input())
	s = ''
	while a > 0:
		if a % 2:
			s += '1'
		else:
			s += '0'
		a //= 2
	while len(s) < 20:
		s += '0'
	l.append(s)
ans = 0
for i in range(m):
	a = l[i]
	b = l[m]
	c = 0
	for j in range(20):
		if a[j] != b[j]:
			c += 1
		if c > k:
			break
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = [int(x) for x in input().split()]
l = []
for i in range(m + 1):
	l.append(int(input()))
ans = 0
for i in range(m):
	x = l[i] ^ l[m]
	count = 0
	while x != 0:
		if x % 2 != 0:
			count += 1
		x //= 2
	if count <= k:
		ans += 1
print(ans)


def decToBin(x):
	return bin(x)[2:]

def compare(x, y):
	check = 0
	alpha = list(decToBin(x))
	beta = list(decToBin(y))
	count = 0
	for i in range(len(alpha), a[0]):
		alpha.insert(0, '0')
	for i in range(len(beta), a[0]):
		beta.insert(0, '0')
	for j in range(0, a[0]):
		if alpha[j] != beta[j]:
			count += 1
	if count <= a[2]:
		check = 1
	return check
b = []
g_count = 0
a = [int(x) for x in input().split()]
for i in range(0, a[1] + 1):
	b.append(int(input()))
for i in range(0, a[1]):
	g_check = compare(b[i], b[a[1]])
	if g_check == 1:
		g_count += 1
print(g_count)


def solve(dp1, k):
	a = dp1[-1]
	ans = 0
	for i in range(len(dp1) - 1):
		s = dp1[i]
		count = 0
		for j in range(20):
			if int(a[j]) ^ int(s[j]) == 1:
				count += 1
		if count <= k:
			ans += 1
	return ans
(n, m, k) = [int(x) for x in input().split()]
if m == 0:
	print(0)
else:
	dp = [0] * (m + 1)
	for i in range(m + 1):
		c = int(input())
		dp[i] = bin(c).replace('0b', '')
		dp[i] = ''.join(['0'] * (20 - len(dp[i]))) + dp[i]
	print(solve(dp, k))


(n, m, k) = [int(x) for x in input().split()]
army = []
for i in range(m + 1):
	army.append(int(input()))
for i in range(m + 1):
	biner = []
	for j in range(n + 1):
		if army[i] >= 2 ** (n - j):
			army[i] = army[i] - 2 ** (n - j)
			biner.append(1)
		else:
			biner.append(0)
	army[i] = biner
count = 0
for i in range(m):
	cek = 0
	for j in range(n + 1):
		cek = cek + abs(army[i][j] - army[m][j])
	if cek <= k:
		count = count + 1
print(count)


(n, m, k) = map(int, input().split())
ls = [int(input()) for i in range(m + 1)]
cnt = 0
var = ls[m]
for i in range(m):
	t = var ^ ls[i]
	t = str(bin(t))
	if t.count('1') <= k:
		cnt += 1
print(cnt)


def count(n):
	r = 0
	while n:
		if n & 1:
			r += 1
		n >>= 1
	return r
(n, m, k) = (int(i) for i in input().split(' '))
p = []
for i in range(m):
	p.append(int(input()))
f = int(input())
ans = 0
for pp in p:
	if count(pp ^ f) <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
f = 0
for i in range(m):
	c = 0
	b = a[i] ^ a[m]
	while b:
		b = b & b - 1
		c += 1
	if c <= k:
		f += 1
print(f)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

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

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout
(n, m, k) = map(int, stdin.readline().split(' '))
l = []
for i in range(m + 1):
	v = deci(int(stdin.readline()))
	l.append(v)
val = l[m]
ans = 0
for i in range(m):
	if diff(val, l[i]) <= k:
		ans = ans + 1
stdout.write(str(ans) + '\n')


(n, m, k) = map(int, input().split())
(*oponenti, fedor) = [int(input()) for i in range(m + 1)]
kamaratov = 0
for oponent in oponenti:
	if bin(oponent ^ fedor).count('1') <= k:
		kamaratov += 1
print(kamaratov)


(n, m, k) = map(int, input().split())
cand = [int(input()) for _ in range(m)]
fedor = int(input())
cnt = 0
for i in cand:
	chk = fedor ^ i
	if bin(chk).count('1') <= k:
		cnt += 1
print(cnt)


(n, m, k) = map(int, input().split())
ar = []
for i in range(m + 1):
	ar.append(int(input()))
check = ar.pop(m)
result = m
for i in range(m):
	c = check ^ ar[i]
	rs = bin(c).count('1')
	if rs > k:
		result -= 1
print(result)


(n, m, k) = map(int, input().split())
bin_len = []
bins = []
diff = 0
ans = 0
for _ in range(m):
	bins.append(bin(int(input()))[2:])
	bin_len.append(len(bins[-1]))
fedor = bin(int(input()))[2:]
fedor_len = len(fedor)
for i in range(m):
	diff = 0
	for j in range(-1, -n - 1, -1):
		if j < -fedor_len:
			d1 = '0'
		else:
			d1 = fedor[j]
		if j < -bin_len[i]:
			d2 = '0'
		else:
			d2 = bins[i][j]
		if d1 != d2:
			diff += 1
			if diff > k:
				break
	else:
		ans += 1
print(ans)


[n, m, k] = list(map(int, input().split(' ')))
result = 0
l = [0] * m
for i in range(0, m):
	l[i] = int(input())
x = int(input())
for i in l:
	t = sum(list(map(int, list('{0:b}'.format(x ^ i)))))
	result += 1 if t <= k else 0
print(result)


def is_friend(a, b, n, k):
	pre_a = '0' * (n - len(a))
	pre_b = '0' * (n - len(b))
	a = pre_a + a
	b = pre_b + b
	dif = 0
	for d in range(n):
		if a[d] != b[d]:
			dif += 1
	if dif > k:
		return False
	return True
(n, m, k) = map(int, input().split())
arr = []
for _ in range(m):
	arr.append(bin(int(input()))[2:])
f = bin(int(input()))[2:]
ans = 0
for m in arr:
	ans += is_friend(f, m, n, k)
print(ans)


(n, m, k) = map(int, input().split())
a = [int(input()) for _ in range(m + 1)]
s = 0
for x in a[:-1]:
	if bin(x ^ a[m]).count('1') <= k:
		s += 1
print(s)


import time

class Profiler(object):

	def __enter__(self):
		self._startTime = time.time()

	def __exit__(self, type, value, traceback):
		print('Elapsed time: {:.3f} sec'.format(time.time() - self._startTime))
(n, m, k) = map(int, input().split())
values = list()
for i in range(m + 1):
	values.append(int(input()))
f = values[m]
values.pop(m)
res = 0
for item in values:
	if bin(f ^ item)[2:].count('1') <= k:
		res += 1
print(res)


(n, m, k) = [int(x) for x in input().split()]
s = 0
a = []
fe = []
f = []
for i in range(m + 1):
	a.append(int(input()))
while a[m] > 0:
	fe.append(a[m] % 2)
	a[m] = a[m] // 2
for i in range(n - len(fe)):
	fe.append(0)
for i in range(m):
	fl = 0
	t = 0
	f.clear()
	while a[i] > 0:
		f.append(a[i] % 2)
		a[i] = a[i] // 2
	for i in range(n - len(f)):
		f.append(0)
	for i in range(n):
		if f[i] != fe[i]:
			t = t + 1
			if t > k:
				fl = 1
				break
	if fl != 1:
		s = s + 1
print(s)


(a, b, c) = map(int, input().split())
list1 = []
for _ in range(b):
	list1.append(int(input()))
fed = int(input())
m = 0
for j in range(0, len(list1)):
	count = 0
	for i in range(0, a):
		if list1[j] >> i & 1 != fed >> i & 1:
			count = count + 1
	if count <= c:
		m += 1
print(m)


def cmp(s1, s2):
	ans = 0
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			ans += 1
	return ans
(n, m, k) = map(int, input().split())
P = [bin(int(input()))[2:].rjust(n, '0') for i in range(m)]
Feda = bin(int(input()))[2:].rjust(n, '0')
ans = 0
for a in P:
	if cmp(Feda, a) <= k:
		ans += 1
print(ans)


(N, M, K) = map(int, input().split())
X = [bin(int(input()))[2:] for _ in range(M + 1)]
X = ['0' * (N - len(x)) + x for x in X]

def count(s, t):
	n = len(s)
	ret = 0
	for i in range(n):
		if s[i] != t[i]:
			ret += 1
	return ret
ans = 0
for x in X[:-1]:
	if count(x, X[-1]) <= K:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
arr = []
for i in range(m + 1):
	inp = int(input())
	arr.append(inp)
fedor = arr[-1]
ans = 0
for i in range(m):
	xor = str(bin(fedor ^ arr[i]))[2:]
	c = 0
	for ele in xor:
		if ele == '1':
			c += 1
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
armies = []
for _ in range(m):
	armies.append(bin(int(input()))[2:].zfill(n))
player = bin(int(input()))[2:].zfill(n)
friends = 0
for army in armies:
	diff = 0
	for i in range(n):
		if player[i] != army[i]:
			diff += 1
	if diff <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
ans = 0
data = [0] * (m + 1)
for a in range(m + 1):
	data[a] = format(int(input()), 'b').zfill(n)
for a in range(m):
	s = list(data[a])
	t = list(data[m])
	anss = 0
	for b in range(n):
		if s[b] != t[b]:
			anss += 1
	if anss <= k:
		ans += 1
print(ans)


import sys
nmk = input().split()
n = int(nmk[0])
m = int(nmk[1])
k = int(nmk[2])
players = [0] * (m + 1)
for i in range(m + 1):
	players[i] = int(input())
friends = 0
fedor = players[m]
for i in range(m):
	x = players[i] ^ fedor
	size = sys.getsizeof(x) * 8
	count = 0
	for j in range(size):
		if x & 1 == 1:
			count += 1
		x = x >> 1
	if count <= k:
		friends += 1
print(friends)


(n, m, k) = [int(x) for x in input().split()]
army = []
for i in range(m + 1):
	army.append(int(input()))
fedor = army[-1]
ans = 0
for a in army[:-1]:
	s = 0
	t = bin(a ^ fedor)
	for c in t:
		if c == '1':
			s += 1
		if s > k:
			break
	else:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
bina = []
ans = 0
for i in range(m):
	l = int(input())
	bina.append(l)
mm = int(input())
for i in range(m):
	xx = mm ^ bina[i]
	x = bin(xx)
	c = 0
	for j in range(len(x)):
		if x[j] == '1':
			c += 1
	if c <= k:
		ans += 1
print(ans)


import os
import sys
from math import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def array():
	return [int(i) for i in input().split()]
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')

def calc(a, b, k):
	n = a ^ b
	c = 0
	while n > 0:
		c += 1
		n = n & n - 1
	if c <= k:
		return True
	return False
(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
my = int(input())
ans = 0
for i in a:
	if calc(i, my, k):
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = []
ans = 0
for i in range(m + 1):
	a.append(int(input()))
x = a[-1]
a = a[:-1]
s = '{0:032b}'.format(x)
for i in a:
	v = '{0:032b}'.format(i)
	stat = True
	c = 0
	for j in range(32):
		if v[j] != s[j]:
			c += 1
			if c > k:
				stat = False
				break
	if stat:
		ans += 1
print(ans)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		(n, m, k) = invr()
		a = []
		for i in range(m):
			a.append(inp())
		army = inp()
		army = bin(army)[2:]
		ans = 0
		for i in range(m):
			arm = bin(a[i])[2:]
			arm = '0' * max(len(army) - len(arm), 0) + arm
			army_t = '0' * max(len(arm) - len(army), 0) + army
			temp = 0
			for j in range(len(army_t)):
				if army_t[j] != arm[j]:
					temp += 1
				if temp > k:
					break
			if temp <= k:
				ans += 1
		print(ans)
	except Exception as e:
		print(e)
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')
main()


(n, m, k) = [int(i) for i in input().split()]
l = []
ans = 0
for i in range(m + 1):
	x = int(input())
	l.append(x)
for i in range(m):
	s = str(bin(l[i] ^ l[-1]))
	if s.count('1') <= k:
		ans += 1
print(ans)


(n, m, k) = list(map(int, input().split()))
b = []
for _ in range(m):
	x = int(input())
	b.append(x)
val = int(input())
ct = 0
for i in range(m):
	ui = b[i]
	p = ui ^ val
	p = bin(p)
	if str(p).count('1') <= k:
		ct += 1
print(ct)


import sys
(n, m, k) = map(int, input().split())
a = [int(sys.stdin.readline()) for _ in range(m + 1)]
fedor = a[-1]
count = 0
for i in range(m):
	b = '{0:b}'.format(a[i] ^ fedor)
	g = 0
	for c in b:
		if c == '1':
			g += 1
	if g <= k:
		count += 1
print(count)


f = lambda : input()
(n, m, k) = map(int, f().split())
armies = []
bits = []

def bit_diff(a, b):
	diff = 0
	ab = 0
	bb = 0
	while a > 0 or b > 0:
		if a > 0:
			ab = a & 1
			a = a >> 1
		else:
			ab = 0
		if b > 0:
			bb = b & 1
			b = b >> 1
		else:
			bb = 0
		if ab != bb:
			diff += 1
	return diff
for i in range(m + 1):
	armies.append(int(f()))
friends = 0
for i in range(0, m):
	if bit_diff(armies[i], armies[m]) <= k:
		friends += 1
print(friends)


[n, m, k] = [int(x) for x in input().split()]
A = []
for _ in range(m):
	i = int(input())
	A.append(i)
var = int(input())
c = 0
for i in A:
	ans = i ^ var
	setB = 0
	while ans > 0:
		if ans & 1:
			setB += 1
		ans >>= 1
		if setB > k:
			break
	if setB <= k:
		c += 1
print(c)


def dec_to_bin(x):
	return bin(x)[2:]

def checkDiff(p1, p2, n, k):
	d1 = n - len(p1)
	d2 = n - len(p2)
	if d1 > 0:
		p1 = '0' * d1 + p1
	if d2 > 0:
		p2 = '0' * d2 + p2
	diff = 0
	for i in range(n):
		if p1[i] != p2[i]:
			diff += 1
	if diff > k:
		return 0
	else:
		return 1

def main():
	(n, m, k) = map(int, input().split())
	players = []
	for i in range(m):
		players.append(int(input()))
	mainPlayer = int(input())
	count = 0
	for i in players:
		if checkDiff(dec_to_bin(mainPlayer), dec_to_bin(i), n, k):
			count += 1
	print(count)
main()


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass

def check(x, k):
	if bin(x).count('1') <= k:
		return True
	return False
test = 1
for t in range(0, test):
	(n, m, k) = list(map(int, input().strip().split()))
	lis = [0] * (m + 1)
	for i in range(m + 1):
		lis[i] = int(input().strip())
	ans = 0
	for i in range(m):
		if check(lis[-1] ^ lis[i], k):
			ans += 1
	print(ans)
	ans = solve()


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
res = 0
for i in range(m):
	res += bin(a[i] ^ a[-1]).count('1') <= k
print(res)


(n, m, k) = [int(x) for x in input().strip().split()]
arr = []
for i in range(0, m + 1):
	arr.append(bin(int(input())))
pivot = arr[-1]
count = 0

def differ(a, b):
	a = a[2:]
	b = b[2:]
	c = 0
	for i in range(0, min(len(a), len(b))):
		if not a[len(a) - i - 1] == b[len(b) - i - 1]:
			c += 1
	alpha = a
	if len(alpha) < len(b):
		alpha = b
	temp = alpha[0:max(len(a), len(b)) - min(len(a), len(b))]
	for i in temp:
		if i == '1':
			c += 1
	return c
for i in arr[:-1]:
	if differ(pivot, i) <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
a = []
ans = 0
for i in range(m):
	a.append(int(input()))
s = int(input())
r = []
for i in range(n):
	r.append(s % 2)
	s = s // 2
for i in range(m):
	j = 0
	c = 0
	g = a[i]
	while j < n and c <= k:
		if r[j] == g % 2:
			j += 1
		else:
			j += 1
			c += 1
		g = g // 2
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
q = []
maxx = -10 ** 10
for i in range(m):
	f = int(input())
	f = bin(f)[2:]
	if maxx <= len(f):
		maxx = len(f)
	q.append(f)
D = bin(int(input()))[2:]
maxx = max(maxx, len(D))
D = '0' * (maxx - len(D)) + D
c = maxx
ans = 0
for i in range(m):
	count = 0
	q[i] = '0' * (maxx - len(q[i])) + q[i]
	for j in range(c):
		if q[i][j] != D[j]:
			count += 1
	if count <= k:
		ans += 1
print(ans)


def bik(x):
	m = ''
	while x != 1:
		m = str(x % 2) + m
		x //= 2
	m = '1' + m
	m = '0' * (20 - len(m)) + m
	return m

def com(a, b):
	count = 0
	for i in range(20):
		if a[i] != b[i]:
			count += 1
	return count
line = list(map(int, input().split()))
let = []
for i in range(line[1]):
	let += [bik(int(input()))]
Fedor = bik(int(input()))
con = 0
for i in let:
	if com(Fedor, i) <= line[2]:
		con += 1
print(con)


(n, m, k) = map(int, input().rstrip().split())
Xi = list()
for i in range(m + 1):
	Xi.append(int(input()))
cnt = 0
for i in range(m):
	val = Xi[i] ^ Xi[m]
	if bin(val).count('1') <= k:
		cnt += 1
print(cnt)


def c(a):
	b = 0
	while a:
		a &= a - 1
		b += 1
	return b
a = list(map(int, input().split()))
b = []
for i in range(a[1] + 1):
	b += [int(input())]
print(len(list(filter(lambda x: x <= a[2], map(c, [i ^ b[-1] for i in b[:-1]])))))


(n, m, k) = [int(i) for i in input().split()]
players = [int(input()) for _ in range(m + 1)]
f = players.pop()
print(sum((bin(f ^ p).count('1') <= k for p in players)))


def c(n):
	s = 0
	while n != 0:
		if n & 1 == 1:
			s += 1
		n = n >> 1
	return s
(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
b = a[m]
s = 0
for i in range(m):
	if c(b ^ a[i]) <= k:
		s += 1
print(s)


from collections import *
from bisect import *
from heapq import *
from fractions import *
import sys
input = sys.stdin.readline
t = 1
while t:
	t -= 1
	(n, m, k) = map(int, input().split())
	s = 0
	l = []
	for i in range(m + 1):
		a = int(input())
		l.append(a)
	for i in range(m):
		if bin(l[-1] ^ l[i]).count('1') <= k:
			s += 1
	print(s)


def dec_to_bin(q, n):
	ans = ''
	while q > 0 or len(ans) < n:
		ans += str(q % 2)
		q //= 2
		if q == 0 and len(ans) < n:
			ans += '0'
	return ans[::-1]
(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(dec_to_bin(int(input()), n))
f = dec_to_bin(int(input()), n)
cnt = 0
for j in range(m):
	dif = abs(len(f) - len(a[j]))
	if dif > k:
		continue
	if len(f) <= len(a[j]):
		for _ in range(len(f)):
			if f[_] != a[j][_]:
				dif += 1
				if dif > k:
					dif = 0
					break
			if _ == len(f) - 1:
				cnt += 1
	else:
		for _ in range(len(a[j])):
			if a[j][_] != f[_]:
				dif += 1
				if dif > k:
					break
			if _ == len(a[j]) - 1:
				cnt += 1
print(cnt)


def fun(a, b, k, n):
	z = 0
	while n > 0:
		if a & 1 != b & 1:
			z += 1
		if z > k:
			break
		n -= 1
		a >>= 1
		b >>= 1
	if z > k:
		return True
	else:
		return False
(n, m, k) = [int(i) for i in input().split()]
l = []
for i in range(m + 1):
	l.append(int(input()))
cnt = m
for i in range(m):
	if fun(l[i], l[m], k, n):
		cnt -= 1
print(cnt)


(n, m, k) = input().split()
(n, m, k) = (int(n), int(m), int(k))
army = []
for i in range(m):
	army.append(int(input()))
fedor = int(input())
ans = 0
for i in range(m):
	t = fedor ^ army[i]
	ones = 0
	while t > 0:
		ones += t % 2
		t = t // 2
	if ones <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
players = [int(input()) for _ in range(m)]
fedor = int(input())
ans = 0
for i in range(m):
	if bin(players[i] ^ fedor)[2:].count('1') <= k:
		ans += 1
print(ans)


import sys
from collections import deque, Counter, OrderedDict, defaultdict

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

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

def input():
	return sys.stdin.readline().strip()
(n, m, k) = get_ints()
a = []
for i in range(m + 1):
	a.append(int(input()))
cnt = 0
fed = a[-1]
for i in range(m):
	d = str(bin(a[i] ^ fed)).count('1')
	if d <= k:
		cnt = cnt + 1
print(cnt)


from sys import stdin, stdout
import math

def compute_diff(marr, cur, n):
	temp = '0' * (n - len(marr[cur])) + marr[cur]
	diff = 0
	for i in range(n):
		if marr[-1][i] != temp[i]:
			diff += 1
	return diff
(n, m, k) = list(map(int, stdin.readline().split()))
marr = []
for i in range(m + 1):
	marr.append(int(stdin.readline().strip()))
for i in range(m + 1):
	marr[i] = str(bin(marr[i]))[2:]
marr[-1] = '0' * (n - len(marr[-1])) + marr[-1]
friends = 0
for i in range(m):
	diff = compute_diff(marr, i, n)
	if diff <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
x = []
for i in range(m):
	e = int(input())
	x.append(e)
key = int(input())
sm = sum((bin(y ^ key).count('1') <= k for y in x))
print(sm)


from sys import stdin
(n, m, k) = map(int, input().split())
i = [int(x) for x in stdin.readlines()]
s = '{0:0' + str(n) + 'b}'
player = map(lambda x: s.format(x), i[:-1])
s = '{0:0' + str(n) + 'b}'
fedor = s.format(i[-1])
res = map(lambda x: sum((a != b for (a, b) in zip(x, fedor))) <= k, player)
print(sum(res))


(n, m, k) = list(map(int, input().split()))
count = 0
ar = []
for x in range(m + 1):
	ar.append(int(input()))
for x in ar[:m]:
	q = bin(x ^ ar[m]).count('1')
	if q <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
x = []
for i in range(0, m + 1):
	x.append(int(input()))
y = [bin(i)[2:] for i in x]
binary = []
for i in y:
	diff = n - len(i)
	for j in range(diff):
		i = '0' + i
	binary.append(i)
fedor = binary[m]
count = 0
res = 0
for i in range(0, m):
	t = binary[i]
	c = 0
	for j in range(0, n):
		if fedor[j] != t[j]:
			c += 1
	if c <= k:
		res += 1
print(res)


(n, m, k1) = map(int, input().split())
l = []
for i in range(m + 1):
	a = int(input())
	x = bin(a)
	l.append(x[2:])
count1 = 0
x = l[m]
k = len(x) - 1
for i in range(m):
	z = l[i]
	j = len(l[i]) - 1
	k = len(x) - 1
	diff = 0
	while j >= 0 and k >= 0:
		if z[j] != x[k]:
			diff = diff + 1
		j = j - 1
		k = k - 1
	while j >= 0:
		if z[j] == '1':
			diff = diff + 1
		j = j - 1
	while k >= 0:
		if x[k] == '1':
			diff = diff + 1
		k = k - 1
	if diff <= k1:
		count1 = count1 + 1
print(count1)


(n, m, k) = [int(s) for s in input().split()]
x = [int(input()) for i in range(m)]
Fedor = int(input())
Fedor_bin = list(str(bin(Fedor)).replace('0b', '').zfill(n))
total = 0
for i in x:
	x_bin = list(str(bin(i)).replace('0b', '').zfill(n))
	rev_Fedor_bin = Fedor_bin[::-1]
	rev_x_bin = x_bin[::-1]
	count = 0
	for j in range(len(Fedor_bin)):
		if rev_Fedor_bin[j] != rev_x_bin[j]:
			count += 1
	else:
		if count <= k:
			total += 1
print(total)


(n, m, k) = [int(x) for x in input().split()]
armies = []
for i in range(m + 1):
	x = format(int(input()), f'0{n}b')
	armies.append(x)
fedor = armies[-1]
count = 0
for x in armies[:len(armies) - 1]:
	diff = 0
	for j in range(n):
		if x[j] != fedor[j]:
			diff += 1
	if diff <= k:
		count += 1
print(count)


string = input()
numbers = string.split(' ')
types = int(numbers[0])
players = int(numbers[1])
armies = int(numbers[2])
binaries = []
for x in range(players + 1):
	army = int(input())
	binary = ''
	while army != 0:
		binary += str(army % 2)
		army = int(army / 2)
	binary += '0' * (types - len(binary))
	binary = binary[::-1]
	binaries.append(binary)
player = binaries[players]
friends = 0
for x in range(players):
	differences = 0
	for y in range(types):
		if binaries[x][y] != player[y]:
			differences += 1
	if differences <= armies:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split(' '))
x = []
for i in range(0, m + 1):
	t = int(input())
	x.append(t)
fedor = x[m]
count = 0
for i in range(0, m):
	tmp = x[i] ^ fedor
	c = bin(tmp).count('1')
	if c <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
A = []
for i in range(m):
	A.append(int(input()))
f = int(input())
count = 0
for i in range(m):
	temp = A[i] ^ f
	c = 0
	while temp > 0:
		c += 1
		temp = temp & temp - 1
	if c <= k:
		count += 1
print(count)


d = input().split()
n = int(d[0])
m = int(d[1])
k = int(d[2])
soldier = []
count = 0
for i in range(0, m + 1):
	soldier.append(int(input()))
for i in range(0, m):
	tmpVal = soldier[m] ^ soldier[i]
	tmpCount = 0
	while tmpVal > 0:
		if tmpVal % 2 == 1:
			tmpVal -= 1
			tmpCount += 1
		tmpVal = tmpVal >> 1
	if tmpCount <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
c = []
for i in range(m):
	c.append(int(input()))
a = int(input())
ans = 0
for i in range(m):
	z = c[i] ^ a
	count = 0
	while z:
		z &= z - 1
		count += 1
	if count <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
arr = []
for _ in range(m + 1):
	arr.append(int(input()))
lol = arr[m]
res = 0
for i in range(m):
	tmp = 0
	for j in range(n + 1):
		if (lol ^ arr[i]) & 2 ** j != 0:
			tmp += 1
	if tmp <= k:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
x = []
for i in range(m + 1):
	x.append(int(input()))
fed = x.pop()

def to_n(s, n):
	out = []
	while s:
		out.append(s % n)
		s = s // n
	return out[::-1]
cnt = 0
for v in x:
	val = fed ^ v
	if sum(to_n(val, 2)) <= k:
		cnt += 1
print(cnt)


(n, m, k) = map(int, input().split())
players = []
for i in range(0, m):
	players.append(int(input()))
fedor = int(input())
answer = 0
for i in range(0, len(players)):
	player = players[i]
	difference = player ^ fedor
	if bin(difference).count('1') <= k:
		answer += 1
print(answer)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	x = int(input())
	a.append(x)
mxa = max(a)
ss = ''
while mxa > 0:
	ss += str(mxa % 2)
	mxa //= 2
mxln = len(ss)
bs = []
for x in a:
	s = ''
	for j in range(mxln):
		s += str(x % 2)
		x //= 2
	bs.append(s)
ferdo = bs[m]
cnt = 0
for i in range(m):
	cct = 0
	for j in range(mxln):
		if ferdo[j] != bs[i][j]:
			cct += 1
	if cct <= k:
		cnt += 1
print(cnt)


(n, m, k) = map(int, input().split())
arr = []
t = 0
for i in range(1, m + 2):
	x = int(input())
	s = str(bin(x))[2:]
	s = '0' * (n - len(s)) + s
	arr.append(s)
for i in range(len(arr) - 1):
	c = 0
	for j in range(len(arr[m])):
		if arr[i][j] != arr[m][j]:
			c += 1
	if c <= k:
		t += 1
print(t)


(n, m, k) = map(int, input().split())
a = [0] * (m + 1)
for i in range(m + 1):
	a[i] = int(input())
ans = 0
for i in range(m):
	jsj = 0
	tmp1 = a[i] ^ a[m]
	for j in range(n):
		tmp = pow(2, j)
		if tmp & tmp1 != 0:
			jsj += 1
		if jsj > k:
			break
	if jsj <= k:
		ans += 1
print(ans)


import sys, math, itertools, random, bisect
from collections import defaultdict
INF = 10 ** 18

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

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

def input():
	return sys.stdin.readline().strip()
mod = 10 ** 9 + 7
test = 1
for _ in range(test):
	(n, m, k) = get_ints()
	a = []
	for i in range(m + 1):
		a.append(int(input()))
	last = [0] * 20
	for i in range(20):
		if a[-1] & 1 << i:
			last[i] = 1
	ans = 0
	for i in range(m):
		x = [0] * 20
		for j in range(20):
			if a[i] & 1 << j:
				x[j] = 1
		diff = 0
		for j in range(20):
			if x[j] != last[j]:
				diff += 1
		if diff <= k:
			ans += 1
	print(ans)


(n, m, k) = map(int, input().split())
soldiers = [int(input()) for _ in range(m)]
f = int(input())
ans = 0
for i in soldiers:
	add = bin(f ^ i).count('1')
	if add <= k:
		ans += 1
print(ans)


def getdiff(a, b):
	return sum([a[i] != b[i] for i in range(n)])
(n, m, k) = list(map(int, input().split()))
armies = [0 for i in range(m)]
for i in range(m):
	armies[i] = bin(int(input()))[2:].rjust(n, '0')
ans = 0
M = bin(int(input()))[2:].rjust(n, '0')
for i in range(m):
	if getdiff(M, armies[i]) <= k:
		ans += 1
print(ans)


X = list(map(int, input().split()))
(Soldiers, Friends) = ([], 0)
for i in range(X[1] + 1):
	Type = bin(int(input()))[2:]
	Temp = '0' * (X[0] - len(Type)) + Type
	Soldiers.append(Temp)
for i in range(X[1]):
	Sum = 0
	for j in range(X[0]):
		if Soldiers[i][j] != Soldiers[-1][j]:
			Sum += 1
	if Sum <= X[2]:
		Friends += 1
print(Friends)


(n, m, k) = map(int, input().split())
a = []
b = []
h = 0
c = 0
for i in range(m + 1):
	a.append(int(input()))
for i in a:
	z = bin(i)
	b.append(z[2:])
b = list(map(str, b))
b[-1] = (n - len(b[-1])) * '0' + b[-1]
for i in range(len(b)):
	if len(b[i]) < len(b[-1]):
		b[i] = (len(b[-1]) - len(b[i])) * '0' + b[i]
for i in b:
	for j in range(len(b[-1])):
		if i[j] != b[-1][j]:
			c += 1
	if c <= k:
		h += 1
	c = 0
print(h - 1)


(n, m, k) = list(map(int, input().split()))
nums = []
for _ in range(m + 1):
	nums.append(int(input()))
fedor = list(map(int, '{0:020b}'.format(nums[-1])))
ans = 0
for i in range(m):
	bits = list(map(int, '{0:020b}'.format(nums[i])))
	k_i = 0
	for j in range(20):
		if bits[j] != fedor[j]:
			k_i += 1
	if k_i <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
arr = []
final = 0
for i in range(0, m + 1):
	arr.append(int(input()))
for i in range(0, m):
	x = arr[i] ^ arr[m]
	count = 0
	for j in range(0, n + 1):
		y = 1 << j
		z = x & y
		if z == y:
			count += 1
	if count <= k:
		final += 1
print(final)


from sys import stdin, stdout
import bisect

def st():
	return list(stdin.readline())

def inp():
	return int(stdin.readline())

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

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

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

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
			n = n - 1
		else:
			a = a * a
			n = n >> 1
	return r

def solve():
	(n, m, k) = mp()
	x = 0
	l = []
	for i in range(m + 1):
		a = inp()
		l.append(a)
	c = 0
	for i in range(m):
		if bin(l[i] ^ l[m]).count('1') <= k:
			c += 1
	pr(c)
solve()


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
f = int(input())

def foo(a, b):
	x = a ^ b
	x = str(bin(x))
	x = x[2:]
	s = sum(map(int, x))
	if s <= k:
		return True
	return False
ans = 0
for i in range(m):
	if foo(f, a[i]):
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
t = [int(input()) for i in range(m)]
(s, f) = (0, int(input()))
for i in t:
	if format(i ^ f, 'b').count('1') <= k:
		s += 1
print(s)


def count_diff_bits(a, b):
	diff = a ^ b
	count = 0
	while diff:
		diff = diff & ~(~diff + 1)
		count += 1
	return count
(n, m, k) = map(int, input().split())
count = 0
armies = []
for i in range(m + 1):
	armies.append(int(input()))
f = armies[-1]
for i in armies[:m]:
	if count_diff_bits(i, f) <= k:
		count += 1
print(count)


def binaryForm(n):
	result = ''
	while n:
		result += str(n % 2)
		n //= 2
	return result

def compare(x, y):
	st1 = binaryForm(x)
	st2 = binaryForm(y)
	maxLength = max(len(st1), len(st2))
	tp = '0'
	tp1 = tp * (maxLength - len(st1))
	tp2 = tp * (maxLength - len(st2))
	st1 += tp1
	st2 += tp2
	result = 0
	for i in range(maxLength):
		if st1[i] != st2[i]:
			result += 1
	return result
(n, m, k) = map(int, input().split())
listNum = []
for _ in range(m):
	listNum.append(int(input()))
compareNum = int(input())
result = 0
for num in listNum:
	if compare(compareNum, num) <= k:
		result += 1
print(result)


from sys import stdin, stdout
input = stdin.readline
(n, m, k) = map(int, input().split())
x = [int(input()) for i in range(m + 1)]
f = bin(x[m])[2:]
f = '0' * (n - len(f)) + f
ans = 0
for i in range(m):
	cur = bin(x[i])[2:]
	cur = '0' * (n - len(cur)) + cur
	al = k
	for i in range(n):
		if cur[i] != f[i]:
			al -= 1
	if al >= 0:
		ans += 1
stdout.write(str(ans))


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
res = ['Yes', 'No']

def bit(n):
	c = 0
	while n:
		if n % 2:
			c += 1
		n //= 2
	return c
test_case = 1
while test_case:
	test_case -= 1
	(n, m, k) = mi()
	a = []
	for _ in range(m + 1):
		a.append(ii())
	for i in range(m):
		a[i] ^= a[-1]
	ans = 0
	for i in a[:m]:
		if bit(i) <= k:
			ans += 1
	print(ans)


import sys
from math import sqrt

def write_to_stdout(res):
	sys.stdout.write('%d\n' % res)

def read_input():
	(n, m, k) = [int(_) for _ in input().rstrip().split()]
	values = []
	for i in range(m + 1):
		values.append(int(input()))
	return (n, m, k, values)

def get_masks(values, n):
	result = [bin(values[i])[2:] for i in range(n)]
	return result

def get_diff(mask, value):
	n_bits = max(len(mask), len(value))
	(mask, value) = (mask[::-1], value[::-1])
	if len(mask) < n_bits:
		mask += '0' * (n_bits - len(mask))
	if len(value) < n_bits:
		value += '0' * (n_bits - len(value))
	count = 0
	for i in range(n_bits):
		if mask[i] != value[i]:
			count += 1
	return count

def get_answer(values, k):
	N = len(values) - 1
	masks = get_masks(values, N)
	ref_value = bin(values[-1])[2:]
	result = [get_diff(masks[i], ref_value) <= k for i in range(N)]
	return sum(result)

def main():
	(n, m, k, values) = read_input()
	answer = get_answer(values, k)
	write_to_stdout(answer)
main()


import math
(n, m, k) = map(int, input().split())
mm = m
nn = n
bin = []
while m + 1:
	m -= 1
	num = int(input())
	temps = ''
	while math.floor(num) != 0:
		r = num % 2
		temps += str(r)
		tempd = n - len(temps)
		num = math.floor(num / 2)
	tempd = nn - len(temps)
	temps += '0' * tempd
	bin.append(temps)
fedor = bin[-1]
c = mm
for i in bin:
	comp = i
	diff = 0
	z = 0
	while z < nn:
		if fedor[z] != comp[z]:
			diff += 1
		z += 1
	if diff > k:
		c -= 1
print(c)


def can(a, b, k):
	x = a ^ b
	return bin(x).count('1') <= k
(n, m, k) = map(int, input().split())
a = [0] * (m + 1)
for i in range(0, m + 1):
	a[i] = int(input())
counter = 0
for i in range(0, m):
	counter += can(a[m], a[i], k)
print(counter)


def pop(x):
	x -= x >> 1 & 1431655765
	x = (x & 858993459) + (x >> 2 & 858993459)
	x = x + (x >> 4) & 252645135
	x += x >> 8
	x += x >> 16
	return x & 63
(n, m, k) = map(int, input().split())
a = []
c = 0
for i in range(m + 1):
	a.append(int(input()))
for i in range(m):
	if pop(a[i] ^ a[m]) <= k:
		c += 1
print(c)


def count_set_bits(n):
	count = 0
	while n:
		count += n & 1
		n >>= 1
	return count
(n, m, k) = [int(i) for i in input().split()]
p = []
res = 0
for i in range(m + 1):
	p.append(int(input()))
for i in range(m):
	n = p[i] ^ p[m]
	if count_set_bits(n) <= k:
		res += 1
print(res)


(a, b, c) = map(int, input().split())
o = [int(input()) for _ in ' ' * (b + 1)]
print(len([x for x in o[:b] if bin(x ^ o[-1]).count('1') <= c]))


def check(i):
	(x, counter) = (armies[i] ^ armies[-1], 0)
	while x:
		counter += x & 1
		x >>= 1
	return counter <= k
(n, m, k) = map(int, input().split())
armies = [int(input()) for x in range(m + 1)]
print(sum(map(check, range(m))))


(n, m, k) = map(int, input().split())
armies = []
allies = 0
for _ in range(m + 1):
	armies.append(int(input()))
player_army = armies[m]
for i in range(m):
	army = armies[i]
	different_forces = army ^ player_army
	number_of_different_forces = bin(different_forces).count('1', 2)
	if number_of_different_forces <= k:
		allies += 1
print(allies)


(n, m, k) = tuple(map(int, input().split()))
players = []
for i in range(m + 1):
	players.append(int(input()))
fedor = players[m]
for i in range(m):
	players[i] ^= fedor
	players[i] = bin(players[i])[2:]
res = 0
for i in range(m):
	if players[i].count('1') <= k:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
arr = []
for i in range(m):
	arr.append(int(input()))
num = int(input())
c = 0
for i in range(m):
	if bin(num ^ arr[i]).count('1') <= k:
		c += 1
print(c)


nmk = list(map(int, input().strip().split()))
n = nmk[0]
m = nmk[1]
k = nmk[2]
vals = []
for i in range(m + 1):
	val = int(input().strip())
	vals.append(val)
fed = vals[m]
friends = 0
for i in vals[:m]:
	c = i ^ fed
	bin_c = bin(c)[2:]
	if bin_c.count('1') <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
d = []
r = 0
for i in range(m):
	d.append(int(input()))
a = int(input())
for i in d:
	if bin(i ^ a).count('1') <= k:
		r += 1
print(r)


(n, m, k) = map(int, input().split())
count = 0
x = []
l = 0
for i in range(m + 1):
	y = bin(int(input())).replace('0b', '')
	x.append(y)
	if len(y) > l:
		l = len(y)
for i in range(len(x)):
	for j in range(l - len(x[i])):
		x[i] = '0' + x[i]
for i in range(len(x) - 1):
	f = 0
	for j in range(l):
		if x[i][j] != x[m][j]:
			f += 1
	if f <= k:
		count += 1
print(count)


def friendable(army1, army2, k):
	diff = 0
	for i in range(len(army1)):
		if army1[i] != army2[i]:
			diff += 1
		if diff > k:
			return False
	return True

def bin_padded(x, n):
	s = bin(x)[2:]
	return (0 if len(s) > n else n - len(s)) * '0' + s
(n, m, k) = [int(x) for x in input().split()]
armies = [bin_padded(int(input()), n) for _ in range(m)]
fedor_army = bin_padded(int(input()), n)
potential_friends = 0
for army in armies:
	potential_friends += friendable(fedor_army, army, k)
print(potential_friends)


(n, m, k) = [int(_) for _ in input().split(' ')]
p = [int(input()) for i in range(0, m + 1)]
fd = p[-1]
ans = 0
for x in iter(p[:-1]):
	t = x ^ fd
	cnt = 0
	while t:
		if t % 2 == 1:
			cnt += 1
		t = t >> 1
	if cnt <= k:
		ans += 1
print(ans)


(n, m, k) = [int(x) for x in input().split(' ')]
army = []
for i in range(m):
	army.append(int(input()))

def armyRepr(army):
	return bin(army)[2:].zfill(n)

def no_diff_k(army1, army2):
	errs = 0
	for i in range(len(army1)):
		if army1[i] != army2[i]:
			errs += 1
	if errs <= k:
		return True
	else:
		return False
friends = 0
Fed_army = armyRepr(int(input()))
for arm in army:
	arm = armyRepr(arm)
	if no_diff_k(arm, Fed_army):
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
l = []
for i in range(m):
	l.append(int(input()))
f = int(input())
c = 0
for i in l:
	r = i ^ f
	r = '{0:b}'.format(r)
	c1 = 0
	for j in range(len(r)):
		if r[j] == '1':
			c1 += 1
	if c1 <= k:
		c += 1
print(c)


(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
army = []
friends = 0
for i in range(m + 1):
	army.append(bin(int(input()))[2:].rjust(n, '0'))
for j in range(m):
	differ = 0
	for i in range(n):
		if not army[j][i] == army[m][i]:
			differ += 1
	if differ <= k:
		friends += 1
print(friends)


def isFriend(i, g, k):
	x = i ^ g
	cnt = 0
	while x > 0:
		cnt += x & 1
		x = x >> 1
	if cnt > k:
		return 0
	else:
		return 1
(n, m, k) = map(int, input().split())
l = []
for _ in range(m + 1):
	l.append(int(input()))
g = l[-1]
ans = 0
for i in l[:-1]:
	ans += isFriend(i, g, k)
print(ans)


gegeven = input().split(' ')
n = int(gegeven[0])
m = int(gegeven[1])
k = int(gegeven[2])
getallen = []
vrienden = 0
for i in range(0, m + 1):
	getallen.append(int(input()))
x = getallen[m]
for j in range(0, m):
	y = getallen[j]
	z = bin(x ^ y)
	aantal = 0
	for l in range(0, len(z)):
		if z[l] == '1':
			aantal += 1
	if aantal <= k:
		vrienden += 1
print(vrienden)


(n, m, k) = map(int, input().rstrip().split(' '))
m = m + 1
al = []
while m:
	z = int(input())
	l = ['0'] * n
	z = list(bin(z)[2:])
	z = z[::-1]
	for i in range(len(z)):
		l[n - 1 - i] = z[i]
	al.append(l[::-1])
	m -= 1
c = len(al) - 1
player = al[-1]
for i in range(len(al) - 1):
	t = 0
	for j in range(n):
		if player[j] != al[i][j]:
			t = t + 1
		if t > k:
			c -= 1
			break
print(c)


x = input()
n = int(x.split()[0])
m = int(x.split()[1])
k = int(x.split()[2])
a = []
friends = 0

def leneq(a, b):
	if len(b) < len(a):
		while len(b) < len(a):
			b = '0' + b
		return b
	else:
		while len(a) < len(b):
			a = '0' + a
		return a
for i in range(m + 1):
	a.append(bin(int(input())))
	a[i] = a[i][2:]
for i in range(m):
	count = 0
	if len(a[i]) < len(a[m]):
		a[i] = leneq(a[i], a[m])
	elif len(a[i]) > len(a[m]):
		a[m] = leneq(a[i], a[m])
	for j in range(len(a[m])):
		if a[i][j] != a[m][j]:
			count += 1
	if count <= k:
		friends += 1
print(friends)


a = []
(n, m, k) = list(map(int, input().split()))
for i in range(m):
	a.append(int(input()))
x = int(input())
ans = 0
for i in range(m):
	y = x ^ a[i]
	diff = 0
	for j in range(n):
		if y >> j & 1:
			diff += 1
	if diff <= k:
		ans += 1
print(ans)


def binario(n):
	return bin(n)[2:]

def canBecomeFriends(number, limit, tamMax):
	uns = 0
	if uns > limit:
		return False
	for i in range(len(number)):
		if number[i] == '1':
			uns += 1
		if uns > limit:
			return False
	return True
(n, m, k) = map(int, input().split())
armys = []
bins = []
for i in range(m + 1):
	army = int(input())
	armys.append(army)
fedorsArmy = armys[-1]
friends = 0
for i in range(m):
	bitwise = armys[i] ^ fedorsArmy
	tamMax = len(binario(max(armys[i], fedorsArmy)))
	bitwise = binario(bitwise)
	if canBecomeFriends(bitwise, k, tamMax):
		friends += 1
print(friends)


from sys import stdin

def main():
	(n, m, k) = map(int, stdin.readline().strip().split())
	f = str(n).join(('{:0>', 'b}')).format
	l = list(map(f, map(int, (stdin.readline().strip() for _ in range(m + 1)))))
	g = l.pop()
	return sum((sum((a != b for (a, b) in zip(g, e))) <= k for e in l))
print(main())


(n, m, k) = map(int, input().split())
players = list()
for i in range(m):
	players.append(int(input()))
fedor = int(input())
num_friends = 0
for p in players:
	if bin(p ^ fedor).count('1') <= k:
		num_friends += 1
print(num_friends)


w = input().split(' ')
n = int(w[0])
m = int(w[1])
k = int(w[2])
arr = []
for i in range(m + 1):
	arr.append(int(input()))
f = 0
ar = []
for i in range(m + 1):
	p = n
	type = ''
	while p > -1:
		q = arr[i] // 2 ** p
		type = type + str(q)
		arr[i] = arr[i] - q * 2 ** p
		p = p - 1
	ar.append(type)
for i in range(m):
	ck = 0
	for j in range(len(ar[0])):
		if ar[i][j] == ar[m][j]:
			ck = ck + 1
	if abs(ck - (n + 1)) < k + 1:
		f = f + 1
print(f)


(n, m, k) = map(int, input().split())
arr = []
for i in range(m):
	arr.append(int(input()))
x = int(input())
out = 0
for i in arr:
	c = 0
	for i in bin(x ^ i)[2:]:
		if i == '1':
			c += 1
	if c <= k:
		out += 1
print(out)


def parsebin(num, N):
	bn = ''
	for expn in range(N - 1, -1, -1):
		if 2 ** expn > num:
			bn += '0'
		else:
			num -= 2 ** expn
			bn += '1'
	return bn
(N, M, K) = list(map(int, input().split()))
players = []
for player in range(M + 1):
	players.append(parsebin(int(input()), N))
fedor = players.pop()
friends = 0
for player in players:
	notmatch = 0
	for pos in range(N):
		if fedor[pos] != player[pos]:
			notmatch += 1
		if notmatch > K:
			break
	if notmatch <= K:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
l = [int(input()) for i in range(m + 1)]
e = l[m]
c = 0
for i in range(m):
	b = l[i] ^ e
	b = bin(b)
	a = b.count('1')
	if a <= k:
		c = c + 1
print(c)


(n, m, k) = map(int, input().split())
y = []
count = 0
for x in range(m + 1):
	b = int(input())
	y += [b]
for x in range(m):
	a = y[m] | y[x]
	t = 2 * list(bin(a)).count('1') - list(bin(y[m])).count('1') - list(bin(y[x])).count('1')
	if t <= k:
		count += 1
print(count)


def dif(x, y):
	c = 0
	while x != 0 or y != 0:
		if x % 2 != y % 2:
			c += 1
		x //= 2
		y //= 2
	return c
(n, m, k) = map(int, input().split())
x = [int(input()) for i in range(m + 1)]
cnt = 0
for i in range(m):
	if dif(x[i], x[m]) <= k:
		cnt += 1
print(cnt)


(n, m, k) = map(int, input().split())
a = list()
for i in range(m + 1):
	a.append(int(input()))
key = a[-1]
ans = 0
for i in range(m):
	if bin(key ^ a[i]).count('1') <= k:
		ans += 1
print(ans)


l = list(map(int, input().split(' ')))
a = []
for i in range(l[1] + 1):
	a.append(int(input()))
c = 0
x = a[len(a) - 1]
a.pop()
for j in range(len(a)):
	if bin(x ^ a[j])[2:].count('1') <= l[2]:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	x = int(input())
	a.append(bin(x))
b = int(input())
b = bin(b)
b = b[2:]
c1 = 0
for i in range(m):
	c = a[i][2:]
	if len(b) > len(c):
		c = '0' * (len(b) - len(c)) + c
		c2 = 0
		for i in range(len(b)):
			if b[i] != c[i]:
				c2 += 1
		if c2 <= k:
			c1 += 1
	else:
		b = '0' * (len(c) - len(b)) + b
		c2 = 0
		for i in range(len(b)):
			if b[i] != c[i]:
				c2 += 1
		if c2 <= k:
			c1 += 1
print(c1)


(n, m, k) = str(input()).split()
n = int(n)
m = int(m)
k = int(k)
line_list = list()
for i in range(m):
	line = bin(int(input()))
	line = ('0' * n + line[2:])[-n:]
	line_list.append(line)
self = bin(int(input()))
self = ('0' * n + self[2:])[-n:]
value = 0
for it in line_list:
	count = 0
	for i in range(n):
		if self[i] != it[i]:
			count += 1
	if k >= count:
		value += 1
print(value)


from sys import stdin, stdout
from collections import Counter

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

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

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

def op(ans):
	return stdout.write(str(ans) + '\n')
from math import ceil
(n, m, k) = ei()
players = []
for i in range(m + 1):
	players.append(ip())
fedor = players.pop()
count = 0
ans = 0
for i in players:
	for j in range(0, 32):
		if fedor >> j & 1 != i >> j & 1:
			count += 1
	if count <= k:
		ans += 1
	count = 0
op(ans)


def count_set_bits(t):
	count = 0
	while t:
		count += t & 1
		t >>= 1
	return count
(n, m, k) = map(int, input().split())
l = [int(input()) for i in range(m + 1)]
a = l[m]
l.remove(a)
friends = 0
for i in range(m):
	t = a ^ l[i]
	c = count_set_bits(t)
	if k >= c:
		friends += 1
print(friends)


def bit(a):
	l = []
	while a != 1:
		q = int(a / 2)
		r = a % 2
		l.append(r)
		a = q
	l.append(1)
	l.reverse()
	return l

def samelen(a, b):
	l1 = len(a)
	l2 = len(b)
	if l1 > l2:
		d = l1 - l2
		for i in range(0, d):
			b.insert(0, 0)
	else:
		d = l2 - l1
		for i in range(0, d):
			a.insert(0, 0)

def compare(a, b):
	samelen(a, b)
	l1 = len(a)
	num = 0
	for i in range(0, l1):
		if a[i] != b[i]:
			num = num + 1
	return num
a = input()
(n, m, k) = list(map(int, a.split()))
b = []
for i in range(0, m + 1):
	c = int(input())
	b.append(c)
c = b[m]
num = 0
for i in b:
	e = bit(i)
	if compare(e, bit(c)) <= k:
		num = num + 1
print(num - 1)


(n, m, k) = map(int, input().split(' '))
l = []
for _ in range(m):
	l.append(int(input()))
fedor = int(input())
res = 0
for i in range(m):
	temp = l[i] ^ fedor
	temp = str(bin(temp))[2:]
	if temp.count('1') <= k:
		res += 1
print(res)


def c(n):
	a = 0
	while n:
		n = n & n - 1
		a += 1
	return a
(n, m, k) = list(map(int, input().split()))
l = []
p = 2
for i in range(m + 1):
	p = int(input())
	l.append(p)
g = 0
for i in range(m):
	if c(l[i] ^ l[m]) <= k:
		g += 1
print(g)


(n, m, k) = [int(i) for i in input().split()]
values = []
for i in range(m):
	values.append(int(input()))
count = 0
p = int(input())
for value in values:
	if bin(p ^ value).count('1') <= k:
		count += 1
print(count)


def intToBin(num: int):
	return '{0:b}'.format(num)

def inpNum():
	return int(input())

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

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

def inpMatrix(rows):
	return [list(map(int, input().split())) for _ in range(rows)]
(n, m, k) = inpNums()
mi = []
for _ in range(m + 1):
	mi.append(inpNum())
f = mi[-1]
ans = 0
for v in mi[:-1]:
	if intToBin(v ^ f).count('1') <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = [int(input()) for _ in range(m + 1)]
r = 0
t = bin(a[-1])[2:]
t = (n - len(t)) * '0' + t
for i in range(m):
	s = bin(a[i])[2:]
	s = (n - len(s)) * '0' + s
	c = 0
	for j in range(n):
		c += s[j] != t[j]
	r += c <= k
print(r)


(n, m, k) = list(map(int, input().split(' ')))
army = [0] * (m + 1)
for i in range(m + 1):
	army[i] = int(input())
count = 0
for j in range(m):
	s = '{0:b}'.format(army[j] ^ army[m])
	if s.count('1') <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
L = []
for i in range(m + 1):
	L.append(int(input()))
p = bin(L[m])[2:]
p = '0' * (n - len(p)) + p
c = 0
s = k
for i in range(m):
	a = bin(L[i])[2:]
	a = '0' * (n - len(a)) + a
	s = k
	for j in range(n):
		if a[j] != p[j]:
			s = s - 1
	if s >= 0:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
ai = [int(input()) for i in range(m)]
num = int(input())
ans = 0
for i in range(m):
	ans += sum(list(map(int, list(bin(num ^ ai[i])[2:])))) <= k
print(ans)


(n, m, k) = map(int, input().split())
(a, c) = ([], 0)
for i in range(m + 1):
	a.append(bin(int(input())).replace('0b', ''))
for i in range(m):
	s = str(int(a[m]) + int(a[i]))
	if s.count('1') <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
a = []
ans = 0
count = 0
for i in range(m + 1):
	x = int(input())
	a.append('0' * (n - len(bin(x)[2:])) + bin(x)[2:])
for i in range(m):
	count = 0
	for j in range(n):
		if a[i][j] != a[-1][j]:
			count += 1
	if count <= k:
		ans += 1
print(ans)


(n, m, chh) = map(int, input().split())
X = []

def dtb(n):
	return bin(n).replace('0b', '')
for i in range(m + 1):
	X.append(dtb(int(input()))[::-1])
count = 0
L = []
for i in X:
	a = set()
	for j in range(len(i)):
		if i[j] == '1':
			a.add(j)
	L.append(a)
for k in range(len(L) - 1):
	y = len(L[-1] - L[k])
	z = len(L[k] - L[-1])
	cont = y + z
	if cont <= chh:
		count += 1
print(count)


read = lambda : map(int, input().split())
(n, m, k) = read()
x = [int(input()) for i in range(m + 1)]
cnt = 0
for i in range(m):
	cur = x[i] ^ x[m]
	if bin(cur).count('1') <= k:
		cnt += 1
print(cnt)


from functools import reduce
(n, m, k) = map(int, input().split())
others = [int(input()) for _ in range(m)]
me = int(input())
diff = list(map(lambda x: bin(x ^ me)[2:].count('1'), others))
good = reduce(lambda x, y: x + 1 if y <= k else x, diff, 0)
print(good)


(n, m, k) = [int(x) for x in input().split(' ')]
players = []
for x in range(m):
	players.append(int(input()))
fedor = int(input())

def countSetBits(n):
	count = 0
	while n:
		count += n & 1
		n >>= 1
	return count
friends = 0
for x in range(m):
	if countSetBits(players[x] ^ fedor) <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split(' '))
x = 0
count = 0
li = []
for i in range(m + 1):
	li.append(int(input()))
m = li[-1]
li.pop()
for i in li:
	x = i ^ m
	s = bin(x)
	if s.count('1') <= k:
		count += 1
print(count)


from sys import stdin, stdout
import math
import random
import time

def sumSquare(a):
	s = 0
	for i in range(len(a)):
		s += a[i] * a[i]
	return s

def C():
	n = int(input())
	a = list(map(int, stdin.readline().split()))
	while True:
		for i in range(n):
			op = False
			for j in range(i + 1, n):
				if a[i] | a[j] > max(a[i], a[j]):
					op = True
					if a[i] > a[j]:
						temp_ai = a[i]
						temp_aj = a[j]
						a[i] = temp_ai | temp_aj
						a[j] = temp_ai & temp_aj
					else:
						temp_ai = a[i]
						temp_aj = a[j]
						a[i] = temp_ai & temp_aj
						a[j] = temp_ai | temp_aj
		if not op:
			break
	print(sumSquare(a))

def num_of_set_bits(n):
	count = 0
	while n > 0:
		n = n & n - 1
		count += 1
	return count

def main():
	(n, m, k) = list(map(int, stdin.readline().split()))
	x = [int(input()) for i in range(m + 1)]
	fedor = x[-1]
	friends = 0
	for i in range(len(x) - 1):
		diff = fedor ^ x[i]
		if num_of_set_bits(diff) <= k:
			friends += 1
	print(friends)
main()


def countOnes(number):
	number = str(bin(number))
	return number.count('1')

def canBeFriends(num1, num2, k):
	return countOnes(num1 ^ num2) <= k
start = input()
variables = [int(x) for x in start.split(' ')]
n = variables[0]
m = variables[1]
k = variables[2]
armyList = []
for i in range(m):
	enemy = int(input())
	armyList.append(enemy)
fedor = int(input())
friendCount = 0
for enemy in armyList:
	if canBeFriends(fedor, enemy, k):
		friendCount += 1
print(friendCount)


import collections
(n, m, k) = (int(x) for x in input().split())
a = [int(input()) for i in range(m + 1)]
f = a[m]
print(sum((1 for x in a if collections.Counter(bin(x ^ f))['1'] <= k)) - 1)


a = [int(x) for x in input().split()]
n = a[0]
m = a[1]
k = a[2]
b = []
ans = 0
for j in range(m + 1):
	b.append(int(input()))
for j in range(m):
	b[j] = bin(b[j] ^ b[-1])
	if b[j].count('1') <= k:
		ans += 1
print(ans)


import sys
import math
import collections
from collections import deque
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
T = 1
for _ in range(T):
	(n, m, k) = list(map(int, stdin.readline().split()))
	(a, ab) = ([], [])
	for i in range(m + 1):
		a.append(int(stdin.readline()))
	mx = max(a)
	ml = len(bin(mx)[2:])
	for i in range(m + 1):
		ab.append(format(a[i], '0' + str(ml) + 'b'))
	ts = {}
	for i in range(m + 1):
		for j in range(ml):
			if ab[i][j] == '1':
				if (ab[i], i) not in ts:
					ts[ab[i], i] = [j + 1]
				else:
					ts[ab[i], i].append(j + 1)
	val = list(ts.values())
	x = set(val[-1])
	val = val[:len(val) - 1]
	ans = 0
	for v in val:
		if len(set(v) ^ x) <= k:
			ans += 1
	print(ans)


import sys

def count_bits_set(n):
	bits_set = 0
	while n > 0:
		bits_set += n & 1
		n = n >> 1
	return bits_set

def test_count_bits_set():
	import random
	for i in range(1000):
		n = random.randint(0, 10000)
		if count_bits_set(n) != bin(n).count('1'):
			print(n)

def main():
	(n, m, k) = map(int, input().split())
	armies = []
	friends = 0
	for i in range(m):
		armies.append(int(input()))
	target = int(input())
	for i in range(m):
		diff_bits = count_bits_set(target ^ armies[i])
		if diff_bits <= k:
			friends += 1
	print(friends)
main()


def decimalToBinary(n):
	return bin(n).replace('0b', '')
(n, m, k) = map(int, input().split())
binary = list()
for i in range(m + 1):
	temp = decimalToBinary(int(input()))
	for j in range(n - len(temp)):
		temp = '0' + temp
	binary.append(temp)
temp = binary[len(binary) - 1]
binary.pop(len(binary) - 1)
ans = 0
for i in binary:
	cnt = 0
	j = 0
	while j < n:
		if temp[j] != i[j]:
			cnt += 1
		j += 1
	if cnt <= k:
		ans += 1
print(ans)


def main():
	(n, m, k) = input().split()
	other_players_army = []
	for i in range(int(m)):
		other_players_army.append(int(input()))
	my_army = int(input())
	result = 0
	for other_player_army in other_players_army:
		difference = bin(other_player_army & 2 ** int(n) - 1 ^ my_army).count('1')
		if difference <= int(k):
			result += 1
	print(result)
main()


(a, b, c) = [int(i) for i in input().split()]
l = []
counti = 0
for i in range(b):
	a = int(input())
	l.append(a)
fed = int(input())
for i in range(b):
	l[i] = l[i] ^ fed
for i in range(b):
	x = bin(l[i]).count('1')
	if x <= c:
		counti += 1
print(counti)


arr1 = str(input())
arr2 = arr1.split()
n = int(arr2[0])
m = int(arr2[1])
k = int(arr2[2])
arr = []
for i in range(m + 1):
	v = int(input())
	arr.append(v)
me = arr[-1]
xor = []
for i in range(m):
	diff = me ^ arr[i]
	xor.append(diff)
count = 0
for i in xor:
	bits = '{0:b}'.format(i)
	countbit = 0
	for j in bits:
		if j == '1':
			countbit += 1
		if countbit > k:
			count += 1
			break
diff = m - count
print(diff)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
fedya = int(input())
fedya = str(bin(fedya)[2:])
fedya = '0' * (n - len(fedya)) + fedya
ans = 0
for bb in a:
	bbb = str(bin(bb)[2:])
	bbb = '0' * (n - len(bbb)) + bbb
	delta = 0
	for i in range(n):
		if bbb[i] != fedya[i]:
			delta += 1
	if delta <= k:
		ans += 1
print(ans)


[n, m, k] = [int(item) for item in input().split(' ')]
soldiers = []

def cb(num, lim):
	counter = 0
	while num and lim:
		counter += num % 2
		num = num >> 1
		lim -= 1
	return counter
for i in range(m):
	soldiers.append(int(input()))
fedor = int(input())
c = 0
for item in soldiers:
	if cb(item ^ fedor, n) > k:
		continue
	c += 1
print(c)


(n, m, r) = map(int, input().split())
a = []
for i in range(m + 1):
	s = bin(int(input()))[2:]
	t = str()
	for i in range(21 - len(s) + 1):
		t += '0'
	a.append(t + s)
res = 0
t = a[len(a) - 1]
for i in range(len(a) - 1):
	ans = 0
	for k in range(len(t)):
		if t[k] != a[i][k]:
			ans += 1
	if ans <= r:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(bin(int(input())))
res = 0
t1 = a[m][2:].rjust(n, '0')
for i in range(m):
	diff = 0
	t2 = a[i][2:].rjust(n, '0')
	for (u, v) in zip(t1, t2):
		diff += u != v
	res += diff <= k
print(res)


def trans_to_binary(num):
	if num == 0:
		return '0'
	else:
		return trans_to_binary(num // 2).lstrip('0') + '01'[num % 2]
(n, m, k) = [int(i) for i in input().split()]
li = []
for i in range(m):
	temp = trans_to_binary(int(input()))
	temp = '0' * (n - len(temp)) + temp
	li.append(temp)
fedor = trans_to_binary(int(input()))
fedor = '0' * (n - len(fedor)) + fedor
ans = 0
for s in li:
	cnt = 0
	for i in range(n):
		if fedor[i] != s[i]:
			cnt += 1
	if cnt <= k:
		ans += 1
print(ans)


from sys import stdin, stdout, setrecursionlimit
input = stdin.readline
flush = stdout.flush
OUT = []

def write(item, sep=' '):
	if type(item) is int:
		OUT.append(str(item))
	elif type(item) is list:
		if type(item[0]) is int:
			OUT.append(sep.join(map(str, item)))
		else:
			OUT.append(sep.join(item))
	else:
		OUT.append(item)

def PRINT():
	print('\n'.join(OUT))
GI = lambda : int(input())
GS = lambda : input()[:-1]
gi = lambda : list(map(int, input().split()))
gs = lambda : input().split()
(n, m, k) = gi()
friends = []
for i in range(m):
	a = GI()
	friends.append(a)
fedor = GI()
y = 0
for i in friends:
	i ^= fedor
	if bin(i).count('1') <= k:
		y += 1
write(y)
PRINT()


(n, m, k) = list(map(int, input().split()))
p = []
sa = []
sol = 0
ki = 0
for x in range(m + 1):
	if x != m:
		p.append(bin(int(input()))[2:])
	else:
		sa.append(bin(int(input()))[2:])
pin = list(str(sa[0]))
for item in p:
	td = list(str(item))
	if abs(len(td) - len(pin)) > 0:
		if len(td) > len(pin):
			for z in range(abs(len(td) - len(pin))):
				pin.insert(0, '0')
		else:
			for z in range(abs(len(td) - len(pin))):
				td.insert(0, '0')
	for x in range(len(td)):
		if td[x] == pin[x]:
			pass
		else:
			sol += 1
	if sol <= k:
		ki += 1
	else:
		pass
	sol = 0
	pin = list(str(sa[0]))
print(ki)


(n, m, k) = [int(x) for x in input().split()]
x = []
for i in range(m + 1):
	x.append(int(input()))
cnt = 0
for i in range(m):
	if bin(x[i] ^ x[-1]).count('1') <= k:
		cnt += 1
print(cnt)


(n, m, k) = [int(x) for x in input().split()]
l = []
for i in range(m + 1):
	l.append(int(input()))
ans = 0
for i in range(m):
	c = 0
	for j in range(n):
		a = 1 << j
		b = l[m] & a
		d = l[i] & a
		if b != d:
			c += 1
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
ans = 0
list1 = []
for i in range(m + 1):
	list1.append(int(input()))
for i in range(m):
	temp = list1[i] ^ list1[m]
	count = 0
	while temp:
		count += temp & 1
		temp >>= 1
	if count <= k:
		ans += 1
print(ans)


(n, m, k) = list(map(int, input().split()))
soldiers = []
for _ in range(m + 1):
	soldiers.append(int(input()))
f = soldiers[-1]
c = 0
for s in soldiers[:-1]:
	if bin(s ^ f).count('1') <= k:
		c += 1
print(c)


n = [int(i) for i in input().split()]
l = []
for i in range(n[1] + 1):
	l.append(int(input()))
s = 0
for i in range(n[1]):
	x = l[i] ^ l[n[1]]
	c = 0
	while x > 0:
		x = x & x - 1
		c += 1
	if c <= n[2]:
		s += 1
print(s)


(n, m, k) = map(int, input().split())
X = []
for i in range(m + 1):
	X.append(int(input()))
z = 0
a = bin(X[-1])[2:]
a = (n - len(a)) * '0' + a
for i in range(m):
	b = bin(X[i])[2:]
	b = (n - len(b)) * '0' + b
	c = 0
	for i in range(n):
		if a[i] != b[i]:
			c += 1
	if c <= k:
		z += 1
print(z)


def f(a):
	return str(bin(a))[2:].count('1')
(n, m, k) = map(int, input().split())
a = [0] * (m + 1)
for i in range(m + 1):
	a[i] = int(input())
ans = 0
for j in range(m):
	if f(a[m] ^ a[j]) <= k:
		ans += 1
print(ans)


def binary(x):
	sum = 0
	i = 0
	list = []
	while x > 0:
		a = x % 2
		x = x // 2
		list.insert(len(list), a)
	for x in list:
		sum += x * 10 ** i
		i += 1
	return sum

def check(x, y, k):
	c = 0
	while x > 0 or y > 0:
		a = x % 10
		b = y % 10
		x = x // 10
		y = y // 10
		if a == b:
			pass
		else:
			c += 1
	if c <= k:
		return 1
	else:
		return 0
(n, m, j) = input().split()
m = int(m)
n = int(n)
j = int(j)
arr = []
i = 0
k = 0
while i < m + 1:
	c = int(input())
	arr.insert(0, binary(c))
	i += 1
for x in arr:
	if check(x, arr[0], j):
		k += 1
print(k - 1)


(n, m, k) = map(int, input().split())
l = [0] * (m + 1)
for i in range(m + 1):
	l[i] = int(input())
for i in range(m):
	l[i] = bin(l[i] ^ l[m]).replace('0b', '')
count = 0
for i in range(m):
	sum = 0
	for j in l[i]:
		if j == '1':
			sum += 1
	if sum <= k:
		count += 1
print(count)


def count_bits(num):
	return bin(num).count('1')
(num_soldiers_types, num_players_minus_one, max_diff_soldier_types) = map(int, input().split())
num_players = num_players_minus_one + 1
players = []
fedor = -1
for i in range(num_players):
	if i == num_players - 1:
		fedor = int(input())
	else:
		players.append(int(input()))
num_poss_friends = 0
for i in range(num_players_minus_one):
	diff_types = fedor ^ players[i]
	if count_bits(diff_types) <= max_diff_soldier_types:
		num_poss_friends += 1
print(num_poss_friends)


(n, m, k) = map(int, input().split())
lst = [int(input()) for i in range(m + 1)]
print(len([i for i in lst if bin(i ^ lst[-1]).count('1') <= k]) - 1)


def bin(n):
	if n == 0:
		return 0
	if n == 1:
		return 1
	else:
		return 10 * bin(n // 2) + n % 2
(n, m, k) = input().split()
m = int(m)
k = int(k)
a = []
for i in range(m + 1):
	a.append(int(input()))
x = a[len(a) - 1]
res = 0
for j in range(len(a) - 1):
	r = x ^ a[j]
	t = str(bin(r))
	s = t.count('1')
	if s <= k:
		res = res + 1
print(res)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	l = int(input())
	a.append(l)
c = 0
for i in range(m):
	count = 0
	for j in range(0, 32):
		if a[i] >> j & 1 != a[m] >> j & 1:
			count = count + 1
	if count <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
s = 0
a = []
for i in range(m + 1):
	a.append(int(input()))
p = a[m]
for i in range(m):
	d = list(map(int, list(bin(a[i] ^ p)[2:])))
	if sum(d) <= k:
		s += 1
print(s)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
f = int(input())
ans = 0
for i in range(m):
	dif = 0
	for j in range(n):
		if f >> j & 1 != a[i] >> j & 1:
			dif += 1
	if dif <= k:
		ans += 1
print(ans)


v = list((int(x) for x in input().split()))
n = v[0]
m = v[1]
k = v[2]
v = list()
for i in range(m + 1):
	v.append(int(input()))
f = bin(v[m])[2:]
f = '0' * (n - len(f)) + f
tot = 0
for i in range(m):
	c = 0
	t = bin(v[i])[2:]
	t = '0' * (n - len(t)) + t
	for j in range(n):
		if t[j] != f[j]:
			c += 1
	if c <= k:
		tot += 1
print(tot)


def solve(a, k):
	ans = 0
	for i in range(len(a) - 1):
		if get(a[i], a[-1]) <= k:
			ans += 1
	return ans

def get(A, B):
	count = 0
	for i in range(0, 32):
		if A >> i & 1 != B >> i & 1:
			count = count + 1
	return count
a = list(map(int, input('').split(' ')))
x = []
for i in range(a[1] + 1):
	x.append(int(input('')))
print(solve(x, a[2]))


def decimalToBinary(n):
	return bin(n).replace('0b', '')

def myXOR(x, y):
	res = 0
	for i in range(31, -1, -1):
		b1 = x & 1 << i
		b2 = y & 1 << i
		b1 = min(b1, 1)
		b2 = min(b2, 1)
		xoredBit = 0
		if b1 & b2:
			xoredBit = 0
		else:
			xoredBit = b1 | b2
		res <<= 1
		res |= xoredBit
	return res
(n, m, k) = map(int, input().split())
l = []
count = 0
for j in range(m):
	l.append(int(input()))
p = int(input())
for j in range(m):
	k3 = myXOR(p, l[j])
	k1 = decimalToBinary(k3)
	k2 = list(k1)
	if k2.count('1') <= k:
		count = count + 1
print(count)


(n, m, k) = map(int, input().split())
a = [int(input()) for i in range(m + 1)]
print(sum([1 for x in a[:m] if sum([(x ^ a[m]) >> i & 1 for i in range(n)]) <= k]))


import math

def count_ones(n):
	count = 0
	if n == 0:
		return count
	log = int(math.log2(n))
	ans = 1 + count_ones(n - 2 ** log)
	return ans
T = input().split()
n = int(T[0])
m = int(T[1])
k = int(T[2])
X = []
ans = 0
for i in range(m + 1):
	Xi = int(input())
	X.append(Xi)
for i in range(m):
	common = X[i] ^ X[m]
	num_of_ones = count_ones(common)
	if num_of_ones <= k:
		ans = ans + 1
print(ans)


from sys import stdin
(n, m, k) = map(int, stdin.readline().split())
li = []
for i in range(m):
	c = int(input())
	li.append(c)
fedor = int(input())
nofr = 0
for i in li:
	temp = fedor
	diff = 0
	lis = i
	while temp > 0 or lis > 0:
		if temp % 2 != lis % 2:
			diff += 1
		temp = temp // 2
		lis = lis // 2
	if diff <= k:
		nofr += 1
print(nofr)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
(n, m, k) = L()
A = [L()[0] for i in range(m)]
f = L()[0]
count = 0
y = bin(f)[2:]
y = '0' * (30 - len(y)) + y
for i in range(m):
	x = bin(A[i])[2:]
	x = '0' * (30 - len(x)) + x
	z = sum((y[j] != x[j] for j in range(30)))
	if z <= k:
		count += 1
print(count)
endtime = time.time()


def differ(a, b):
	c = a ^ b
	s = list(bin(c))
	return s.count('1')
sp = input()
(n, m, k) = list(map(int, sp.split()))
l = []
for i in range(m + 1):
	l.append(int(input()))
mi = l[-1]
count = 0
for each in l[:-1]:
	if differ(each, mi) <= k:
		count += 1
print(count)


(n, m, k) = list(map(int, input().split()))
p = []
for i in range(0, m + 1):
	p.append(int(input()))
q = 0
for i in range(0, m):
	a = p[m] ^ p[i]
	a = str(bin(a))
	if a.count('1') <= k:
		q = q + 1
print(q)


[n, m, k] = [int(i) for i in input().split()]
big = []
for i in range(m):
	big.append(bin(int(input()))[2:])
s = bin(int(input()))[2:]
s = '0' * (n - len(s)) + s
tot = 0
count = 0
for i in range(m):
	big[i] = '0' * (n - len(big[i])) + big[i]
	count = 0
	for j in range(n):
		count += 1 if big[i][j] != s[j] else 0
	if count <= k:
		tot += 1
print(tot)


(n, m, k) = map(int, input().split())
l = []
ans = 0
for i in range(m + 1):
	x = int(input())
	l.append(bin(x).replace('0b', '').zfill(32))
for i in range(m):
	cnt = 0
	for j in range(32):
		if l[m][j] != l[i][j]:
			cnt += 1
	if cnt <= k:
		ans += 1
print(ans)


def count_bits(Num):
	count = 0
	while Num > 0:
		Rem = Num % 2
		Num = Num // 2
		if Rem == 1:
			count += 1
	return count

def main():
	(n, m, k) = map(int, input().split())
	a = []
	for _ in range(0, m):
		a.append(int(input()))
	fed = int(input())
	friends = 0
	for army in a:
		if count_bits(fed ^ army) <= k:
			friends += 1
	print(friends)
main()


(n, m, k) = [int(x) for x in input().split()]
p = []
for i in range(m + 1):
	x = int(input())
	b = bin(x)
	a = list(b)
	a = a[2:]
	a = [0] * (n - len(a)) + a
	p.append(a)
fedor = p[m]
p.remove(fedor)
num = 0
for i in range(m):
	li = []
	for j in range(n):
		x = abs(int(p[i][j]) - int(fedor[j]))
		li.append(x)
	s = sum(li)
	if s <= k:
		num += 1
print(num)


def difference(x1, x2):
	return bin(x1 ^ x2).count('1')
(n, m, k) = map(int, input().split())
x = []
for i in range(m + 1):
	xi = int(input())
	x.append(xi)
ans = 0
for i in range(m):
	if difference(x[i], x[m]) <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = []
ans = 0
for i in range(m):
	a.append(int(input()))
x = int(input())
for i in range(m):
	z = x ^ int(a[i])
	z = '{0:b}'.format(z)
	c = z.count('1')
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = (int(i) for i in input().split())
armies = []
for i in range(m + 1):
	armies.append(int(input()))
friends = 0
for i in range(len(armies) - 1):
	diff = armies[i] ^ armies[m]
	diff = str(bin(diff)[2:])
	count = 0
	for c in diff:
		if c == '1':
			count = count + 1
	if count <= k:
		friends = friends + 1
print(friends)


def diff(a, b, k):
	nb = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			nb += 1
		if nb > k:
			return False
	return True
(n, m, k) = map(int, input().split(' '))
players = []
for i in range(m):
	players.append('{0:b}'.format(2097152 + int(input())))
fedor = '{0:b}'.format(2097152 + int(input()))
nb = 0
for p in players:
	if diff(fedor, p, k):
		nb += 1
print(nb)


(n, m, k) = [int(i) for i in input().split()]
army = [int(input()) for i in range(m + 1)]
ans = 0
for i in range(m):
	difference = bin(army[i] ^ army[-1]).replace('0b', '')
	if difference.count('1') <= k:
		ans += 1
print(ans)


(n, m, k) = [int(x) for x in input().split()]
army = []
friend = 0
for i in range(m + 1):
	army.append(int(input()))
Fedor = army[m]
for j in range(m):
	t = bin(army[j] ^ Fedor)
	difference = 0
	for a in t:
		if a == '1':
			difference += 1
	if difference <= k:
		friend += 1
print(friend)


import os, sys
from collections import defaultdict, Counter
from io import BytesIO, IOBase
from math import ceil

def main():
	(n, m, k) = map(int, input().split())
	a = [int(input()) for i in range(m + 1)]
	an = 0
	for i in range(m):
		p = bin(a[i] ^ a[m]).count('1')
		if p <= k:
			an += 1
	print(an)
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')
main()


a = list(map(int, input().split(' ')))
c = 0
n = a[0]
m = a[1]
k = a[2]
l = [i for i in range(1, m + 2)]
for i in range(0, len(l)):
	l[i] = int(input())
for i in range(0, len(l)):
	l[i] = int(l[i])
for i in range(0, len(l) - 1):
	a = l[i] ^ l[-1]
	a = bin(a)
	if a.count('1') <= k:
		c += 1
print(c)


def isFriend(all_armies, fedors_army, k):
	num_friends = 0
	for army in all_armies:
		match = army ^ fedors_army
		num_friends += 1 if bin(match).count('1') <= k else 0
	return num_friends
	return bin(match).count('1') <= k
num_friends = 0
all_armies = []
(n, m, k) = map(int, input().split())
for _ in range(m):
	all_armies.append(int(input()))
fedors_army = int(input())
print(isFriend(all_armies, fedors_army, k))


def one_counter(number):
	count = 0
	a = bin(number)
	for letters in a:
		if letters == '1':
			count += 1
	return count
a = input()
list_a = list(map(int, a.split()))
n = list_a[0]
m = list_a[1]
k = list_a[2]
soldier_type = []
for numbers in range(m + 1):
	a = int(input())
	soldier_type.append(a)
f = soldier_type[-1]
friend_counter = 0
for i in range(m):
	if one_counter(soldier_type[i] ^ f) <= k:
		friend_counter += 1
print(friend_counter)


(n, m, k) = map(int, input().split())
x = []
f = 0
for i in range(m + 1):
	xi = int(input())
	x.append(xi)
for j in range(m):
	a = x[m] ^ x[j]
	b = bin(a)
	c = str(b[2:]).count('1')
	if c <= k:
		f += 1
print(f)


(a, b, c) = map(int, input().split())
l = []
cn = 0
d = 0
for i in range(b + 1):
	n = int(input())
	l.append(n)
for i in range(b):
	cn = 0
	for j in range(30, -1, -1):
		if l[i] & 1 << j ^ l[b] & 1 << j:
			cn += 1
	if cn <= c:
		d += 1
print(d)


def differ(x, y):
	kk = 0
	for i in range(len(x)):
		if x[i] != y[i]:
			kk += 1
	return kk
sold = []
(n, m, k) = map(int, input().split(' '))
for i in range(m):
	i2 = input()
	bina = bin(int(i2))[2:]
	sold.append('0' * (n - len(bina)) + bina)
i2 = input()
bina = bin(int(i2))[2:]
last = '0' * (n - len(bina)) + bina
tot = 0
for i in sold:
	if differ(i, last) <= k:
		tot += 1
print(tot)


def f():
	(n, m, k) = [int(i) for i in input().split()]
	g = [0] * (m + 2)
	for i in range(1, m + 2):
		g[i] = int(input())
	a = 0
	for i in g[1:-1]:
		if bin(g[-1] ^ i).count('1') <= k:
			a += 1
	return a
print(f())


(n, m, k) = map(int, input().split())
L = []
N = []
M = 0
for i in range(m + 1):
	L += [bin(int(input())).replace('0b', '')]
	M = max(M, len(L[i]))
for i in range(m + 1):
	p = ['0' * (M - len(L[i])) + L[i]]
	N += p
f = N[-1]
t = 0
for i in N:
	t += 1
	s = 0
	for j in range(len(f)):
		if i[j] != f[j]:
			s += 1
			if s == k + 1:
				t -= 1
				break
print(t - 1)


(n, m, k) = map(int, input().split())

def ones(x):
	s = set()
	for i in range(len(x)):
		if x[::-1][i] == '1':
			s.add(i + 1)
	return s
players = []
for i in range(m):
	x = int(input())
	players.append(ones(bin(x)))
fedor = int(input())
s = 0
for i in range(m):
	if len(ones(bin(fedor)) ^ players[i]) <= k:
		s += 1
print(s)


import sys
from collections import *
from heapq import *
import math
import bisect
(n, m, k) = map(int, input().split())
fed = ''
all = []
for i in range(m + 1):
	if i == m:
		x = int(input())
		fed = bin(x)[2:]
	else:
		x = int(input())
		all.append(bin(x)[2:])
fed = fed[::-1]
cnt = 0
for i in all:
	i = i[::-1]
	temp = 0
	maxx = max(len(fed), len(i))
	fed += (maxx - len(fed)) * '0'
	i += (maxx - len(i)) * '0'
	for j in range(maxx):
		if i[j] != fed[j]:
			temp += 1
	if temp <= k:
		cnt += 1
print(cnt)


(n, m, k) = map(int, input().split())
l = []
while m + 1 > 0:
	x = int(input())
	l.append(x)
	m -= 1
nr = 0
for i in range(len(l) - 1):
	c = l[i] ^ l[len(l) - 1]
	if bin(c).count('1') <= k:
		nr += 1
print(nr)


(n, m, k) = map(int, input().split())
p = []

def bit(x):
	s = ''
	while x != 0:
		s += str(x % 2)
		x //= 2
	s = s[::-1]
	return s
for i in range(m):
	p.append(int(input()))
h = int(input())
h = bit(h)
answer = 0
for i in range(m):
	f = bit(p[i])
	if len(h) < len(f):
		h = '0' * (len(f) - len(h)) + h
	if len(f) < len(h):
		f = '0' * (len(h) - len(f)) + f
	u = 0
	for i in range(len(h)):
		if h[i] != f[i]:
			u += 1
		if u == k + 1:
			break
	else:
		answer += 1
print(answer)


answer = 0
forces = list()
(n, m, k) = [int(i) for i in input().split()]
for i in range(m):
	forces.append(int(input()))
fyodor = int(input())
for i in range(m):
	diff = forces[i] ^ fyodor
	if diff != 0:
		counter = 1
		while diff > 1:
			if diff % 2 == 1:
				diff -= 1
				counter += 1
			else:
				diff = int(diff / 2)
	else:
		counter = 0
	if counter <= k:
		answer += 1
print(answer)


(n, m, k) = map(int, input().split())
arr = []
for i in range(m + 1):
	arr.append(int(input()))
(v, y) = ('', arr[-1])
while y != 0:
	v += str(y % 2)
	y //= 2
(h, v, ans) = (m - 1, v[::-1], 0)
while h >= 0:
	(f, t) = (arr[h], '')
	while f != 0:
		t += str(f % 2)
		f //= 2
	(n1, n2, t) = (len(t), len(v), t[::-1])
	if n1 > n2:
		v = '0' * (n1 - n2) + v
	elif n1 < n2:
		t = '0' * (n2 - n1) + t
	c = 0
	for (i, j) in enumerate(v):
		if j != t[i]:
			c += 1
	if c <= k:
		ans += 1
	h -= 1
print(ans)


(n, m, k) = map(int, input().split())
l = list((int(input()) for i in range(m + 1)))
print(sum([bin(l[m] ^ y).count('1') <= k for y in l]) - 1)


inp = lambda : map(int, input().split(' '))
(n, m, k) = inp()
s = []
for i in range(m):
	s.append(int(input()))
m1 = int(input())
c = 0
for i in s:
	a = i ^ m1
	if bin(a).count('1') <= k:
		c += 1
print(c)


def discos():
	(n, m, k) = input().split()
	(n, m, k) = [int(n), int(m), int(k)]
	nums = list()
	count = int()
	for x in range(0, m + 1):
		numsa = int(input())
		nums.append(numsa)
	for x in range(0, len(nums) - 1):
		nums[x] = nums[x] ^ nums[len(nums) - 1]
	for x in range(0, len(nums) - 1):
		if bin(nums[x]).count('1') <= k:
			count += 1
	print(count)
discos()


def main():
	s = input().split()
	n = int(s[0])
	m = int(s[1])
	k = int(s[-1])
	players = []
	for i in range(m):
		player = int(input())
		players.append(player)
	fedor = int(input())
	army = []
	for i in range(n):
		army.append(fedor % 2)
		fedor = fedor // 2
	output = 0
	for i in range(m):
		dif = 0
		j = 0
		t = 0
		while j < len(army) and t < n:
			if players[i] % 2 != army[j]:
				dif += 1
			j += 1
			players[i] = players[i] // 2
			t += 1
		if dif <= k:
			output += 1
	print(output)
main()


(n, m, k) = map(int, input().split())
arr = list()
for i in range(m):
	temp = int(input())
	arr.append(temp)
fedor = int(input())
count = 0
for i in range(m):
	temp = fedor
	sumV = bin(arr[i] ^ temp).count('1')
	if sumV <= k:
		count += 1
print(count)


import sys
inf = float('inf')
(mod, MOD) = (1000000007, 998244353)

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

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

def input():
	return sys.stdin.readline().strip()

def solve(x, i):
	z = x ^ i
	count = 0
	while z:
		count += 1
		z &= z - 1
	return count
(n, m, k) = get_ints()
Arr = []
for i in range(m):
	Arr.append(int(input()))
x = int(input())
count = 0
for i in Arr:
	if solve(x, i) <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split(' '))
l = []
for _ in range(m):
	l.append(int(input()))
m1 = int(input())
su = 0

def nums(n):
	n = bin(n)
	t = 0
	for i in str(n):
		if i == '1':
			t += 1
	return t
for i in range(m):
	if nums(m1 ^ l[i]) <= k:
		su += 1
print(su)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	l.append(int(input()))
(f, ans) = (l[m], 0)
for i in range(m):
	s = str(bin(f ^ l[i]))
	s = s[2:]
	c = 0
	for i in range(len(s)):
		if s[i] == '1':
			c += 1
	if c <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
v = []
for i in range(m):
	a = int(input())
	v.append(bin(a))
a = bin(int(input()))
c = 0
a = a[2:]
for i in range(m):
	v[i] = v[i][2:]
	bc = a
	m = max(len(v[i]), len(a))
	v[i] = v[i].zfill(m)
	bc = bc.zfill(m)
	v[i] = [ord(a) ^ ord(b) for (a, b) in zip(v[i], bc)]
	if v[i].count(1) <= k:
		c = c + 1
print(c)


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
dgl = lambda : list(map(int, input()))
il = lambda : list(map(int, input().split()))
(n, m, k) = f()
l = []
fr = 0
for _ in range(m):
	x = bin(ii())[2:]
	l.append('0' * (n - len(x)) + x)
z = bin(ii())[2:]
z = '0' * (n - len(z)) + z
for i in range(m):
	c = 0
	for (p, q) in zip(l[i], z):
		if p != q:
			c += 1
	if c <= k:
		fr += 1
print(fr)


(n, m, k) = input().split(' ')
n = int(n)
m = int(m)
k = int(k)
a = []
Sum = 0
for i in range(m + 1):
	f = input()
	f = int(f)
	d = bin(f)
	d = d[2:]
	s = '0' * (n - len(d))
	d = s + d
	a.append(d)
jj = a[-1]
for j in range(len(a) - 1):
	c = 0
	for k1 in range(n):
		if a[j][k1] != jj[k1]:
			c = c + 1
	if c <= k:
		Sum = Sum + 1
print(Sum)


from sys import stdin
(n, m, k) = map(int, stdin.readline().split())
l = []
for i in range(m + 1):
	l.append(int(stdin.readline().rstrip()))
c = 0
for i in range(m):
	p = l[i] ^ l[m]
	b = bin(p).replace('0b', '')
	if b.count('1') <= k:
		c += 1
print(c)


def calc(a, b):
	(x, y) = ([], [])
	for i in range(20):
		if a > 0:
			x.append(a % 2)
			a = a // 2
		else:
			x.append(0)
	for i in range(20):
		if b > 0:
			y.append(b % 2)
			b = b // 2
		else:
			y.append(0)
	cont = 0
	for i in range(20):
		if x[i] != y[i]:
			cont += 1
	return cont
(n, m, k) = map(int, input().split())
arr = []
for i in range(m + 1):
	a = int(input())
	arr.append(a)
ans = 0
for i in range(m):
	cnt = calc(a, arr[i])
	if cnt <= k:
		ans += 1
print(ans)


inp = input()
inp = inp.split()
players = []
friends = 0
for _ in range(0, int(inp[1])):
	players.append(int(input()))
fedor = int(input())
for i in players:
	test = fedor ^ i
	sum = test % 2
	div = test // 2
	while div > 0:
		sum += div % 2
		div = div // 2
	if sum <= int(inp[2]):
		friends += 1
print(friends)


import collections
mas = []

def bit(x):
	ans = []
	while x != 1:
		ans.append(x % 2)
		x //= 2
	ans.append(x)
	ans = ans[::-1]
	return ans
(n, m, k) = map(int, input().split())
for i in range(m):
	x = int(input())
	mas.append(bit(x))
plus = int(input())
plus = bit(plus)
max = 0
answer = 0
for i in mas:
	if len(i) > max:
		max = len(i)
if len(plus) > max:
	max = len(plus)
for i in range(len(mas)):
	mas[i] = mas[i][::-1]
	for j in range(max - len(mas[i])):
		mas[i].append(0)
	mas[i] = mas[i][::-1]
plus = plus[::-1]
for j in range(max - len(plus)):
	plus.append(0)
plus = plus[::-1]
answer = 0
for i in mas:
	ans = 0
	for j in range(len(i)):
		if i[j] != plus[j]:
			ans += 1
	if ans <= k:
		answer += 1
print(answer)


(n, m, k) = map(int, input().split())
army = list()
for i in range(m):
	army.append(int(input()))
fador = int(input())
answer = 0
for i in army:
	if bin(i ^ fador).count('1') <= k:
		answer += 1
print(answer)


(n, m, k) = map(int, input().split())
x = []
ans = 0
for i in range(m + 1):
	x.append(int(input()))
for i in range(m):
	if str(bin(x[i] ^ x[m]))[2:].count('1') <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
army = []
for i in range(m + 1):
	army.append(int(input()))
fed = army[-1]
ans = 0
for i in range(m):
	temp = bin(fed ^ army[i])
	if temp.count('1') <= k:
		ans += 1
print(ans)


(n, m, k) = [int(p) for p in input().split()]
arr = []
for i in range(m + 1):
	arr.append(int(input()))
count = 0
fedor = arr[-1]
for i in range(len(arr) - 1):
	res = bin(fedor ^ arr[i])
	if res.count('1') <= k:
		count += 1
print(count)


def bin_rep(num, pos=None):
	answer = []
	while num:
		z = num >> 1
		if z * 2 == num:
			answer.append(0)
		else:
			answer.append(1)
		num >>= 1
	if pos:
		answer += [0] * (pos - len(answer))
	return answer
(n, m, k) = list(map(int, input().split()))
nums = []
for i in range(m + 1):
	nums.append(int(input()))
fed = nums[-1]
ans = 0
for i in range(m):
	if sum(bin_rep(fed ^ nums[i])) <= k:
		ans += 1
print(ans)


(n, m, k) = [int(a) for a in input().split()]
friends = 0
soldiers = [0] * (m + 1)
for x in range(m + 1):
	soldiers[x] = int(input())
Fedor = soldiers[-1]
for x in range(m):
	if len([int(a) for a in bin(Fedor ^ soldiers[x])[2:] if int(a)]) <= k:
		friends += 1
print(friends)


def countSetBits(num):
	binary = bin(num)
	setBits = [ones for ones in binary[2:] if ones == '1']
	return len(setBits)
(n, m, k) = map(int, input().split())
l = []
for i in range(0, m + 1):
	l.append(int(input()))
a = 0
for i in range(0, m):
	if countSetBits(l[m] ^ l[i]) <= k:
		a += 1
print(a)


(n, m, k) = [int(x) for x in input().split(' ')]
t = [None] * (m + 1)
for i in range(0, m + 1):
	t[i] = int(input())
Fedor = list(bin(t[-1])[2:])
ans = 0
for i in range(0, m):
	count = 0
	player = list(bin(t[i])[2:])
	while len(Fedor) < len(player):
		Fedor.insert(0, '0')
	while len(player) < len(Fedor):
		player.insert(0, '0')
	for j in range(0, len(Fedor)):
		if player[j] != Fedor[j]:
			count += 1
	if count <= k:
		ans += 1
print(ans)


(a, b, c) = map(int, input().split())
d = []
count = 0
for i in range(b + 1):
	l = int(input())
	d += [l]
f = d[-1]
for i in range(len(d) - 1):
	e = d[i] ^ f
	if bin(e).count('1') <= c:
		count += 1
print(count)


def countBits(i):
	ret = 0
	while i:
		if i & 1:
			ret += 1
		i >>= 1
	return ret
(n, m, k) = list(map(int, input().split()))
players = []
for i in range(m):
	players.append(int(input()))
fedor = int(input())
res = 0
for player in players:
	if countBits(fedor ^ player) <= k:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
a = [int(input()) for __ in range(m)]
x = int(input())
ans = 0
for y in a:
	if bin(x ^ y).count('1') <= k:
		ans += 1
print(ans)


data = list(map(int, input().split(' ')))
n = data[0]
m = data[1]
k = data[2]
armies = []
for i in range(m + 1):
	armies.append(int(input()))
friend_count = 0
for i in range(m):
	if sum(list(map(int, list('{0:b}'.format(armies[m] ^ armies[i]))))) <= k:
		friend_count += 1
print(friend_count)


(n, m, k) = map(int, input().split())
solider = []
for a in range(m + 1):
	b = int(input())
	solider.append(b)
fedor = ''
for c in range(n - 1, -1, -1):
	if 2 ** c <= solider[m]:
		solider[m] -= 2 ** c
		fedor += '1'
	else:
		fedor += '0'
friend = 0
for i in range(m):
	count = 0
	for j in range(n - 1, -1, -1):
		if 2 ** j <= solider[i]:
			solider[i] -= 2 ** j
			if fedor[n - 1 - j] != '1':
				count += 1
		else:
			solider[i] = solider[i]
			if fedor[n - 1 - j] != '0':
				count += 1
	if count <= k:
		friend += 1
print(friend)


(n, m, k) = map(int, input().split())
(*a, t) = [int(input()) for _ in range(m + 1)]
print(sum((bin(_ ^ t).count('1') <= k for _ in a)))


(n, m, k) = [int(x) for x in input().split()]
armies = []
for __ in range(m):
	army = int(input())
	armies.append(army)
player = int(input())
pairs = 0
for i in range(m):
	diff = bin(player ^ armies[i])
	if diff.count('1') <= k:
		pairs += 1
print(pairs)


def friendsCount(arr, k):
	friends = 0
	fedor = arr[len(arr) - 1]
	for i in range(0, len(arr) - 1):
		xor = fedor ^ arr[i]
		diffBits = 0
		while 1:
			if xor == 0:
				break
			if xor % 2 == 1:
				diffBits = diffBits + 1
			xor = xor // 2
		if diffBits <= k:
			friends = friends + 1
	print(friends)
nmk = list(map(int, input().strip().split()))
arr = []
for i in range(0, nmk[1] + 1):
	scratch = int(input())
	arr.append(scratch)
friendsCount(arr, nmk[2])


def binary(x):
	temp = []
	while x:
		if x % 2 == 0:
			temp.append(0)
		else:
			temp.append(1)
		x = x // 2
	return temp.count(1)
l = [int(i) for i in input().split()]
x = []
for i in range(l[1] + 1):
	x.append(int(input()))
temp = []
for i in range(l[1]):
	temp.append(x[i] ^ x[l[1]])
count = 0
for i in temp:
	p = binary(i)
	if p <= l[2]:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
armies = []
friends = 0
for x in range(m + 1):
	armies.append(int(input()))
for i in range(m):
	armies[i] = bin(armies[i] ^ armies[-1])
	if armies[i].count('1') <= k:
		friends += 1
print(friends)


a = list(map(int, input().split(' ')))
b = []
for i in range(0, a[1]):
	b.append(int(input()))
fedor = int(input())
temp = 0
fr = 0
for i in b:
	temp = fedor ^ i
	if bin(temp).count('1') <= a[2]:
		fr = fr + 1
print(fr)


def dif(a, b):
	(b, a, ans) = (max(a, b), min(a, b), 0)
	(c, d) = ([], [])
	i = 0
	while a > 0:
		if a % 2 == 1:
			c.append(1)
		else:
			c.append(0)
		a //= 2
		i += 1
	i = 0
	while b > 0:
		if b % 2 == 1:
			d.append(1)
		else:
			d.append(0)
		b //= 2
	for i in range(len(c)):
		if c[i] != d[i]:
			ans += 1
	for i in range(len(c), len(d)):
		if d[i] == 1:
			ans += 1
	return ans
(n, m, k) = map(int, input().split())
ans = 0
x = []
for i in range(m + 1):
	x.append(int(input()))
for i in range(m):
	if dif(x[i], x[m]) <= k:
		ans += 1
print(ans)


import time, math, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

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

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

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def solve():
	(n, m, k) = IP()
	l = []
	for i in range(m + 1):
		l.append(II())
	p1 = l[-1]
	p1 = bin(p1)[2:].rjust(20, '0')
	fr = 0
	for i in range(m):
		x = bin(l[i])[2:].rjust(20, '0')
		dis = 0
		for i in range(20):
			if x[i] != p1[i]:
				dis += 1
		if dis <= k:
			fr += 1
	print(fr)
solve()


while True:
	try:

		def count_one(num):
			s = 0
			while num != 0:
				s += num % 2
				num //= 2
			return s

		def solution(n, m, k, fedr, a):
			frnd = 0
			for i in range(m):
				num = a[i] ^ fedr
				num = count_one(num)
				if num <= k:
					frnd += 1
			print(frnd)

		def read():
			(n, m, k) = map(int, input().split())
			a = []
			fedr = 0
			for i in range(m):
				a.append(int(input()))
			fedr = int(input())
			solution(n, m, k, fedr, a)
		if __name__ == '__main__':
			read()
	except EOFError:
		break


def binary(n, k):
	l = []
	quotient = n // 2
	rem = n % 2
	while quotient != 0:
		l.append(rem)
		rem = quotient % 2
		quotient = quotient // 2
	l.append(rem)
	for i in range(k - len(l)):
		l.append(0)
	l.reverse()
	lis = list(map(str, l))
	ans = ''.join(lis)
	return ans

def comparison(s1, s2):
	ansc = 0
	for i in range(len(s1)):
		if s1[i] != s2[i]:
			ansc += 1
	return ansc
inp = input().split()
n = int(inp[0])
m = int(inp[1])
k = int(inp[2])
l = []
ansq = 0
for i in range(m + 1):
	xi = int(input())
	l.append(xi)
for j in range(m):
	if comparison(binary(l[j], n), binary(l[-1], n)) <= k:
		ansq += 1
print(ansq)


(n, m, k) = [int(i) for i in input().split()]
a = []
for i in range(m + 1):
	x = int(input())
	x = bin(x)[2:]
	x = '0' * (n - len(x)) + x
	a.append(x)
team = 0
for i in range(m):
	num = 0
	for b in range(n):
		if a[i][b] != a[m][b]:
			num += 1
	if num <= k:
		team += 1
print(team)


import sys, os
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
from itertools import permutations
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 10 ** 9 + 7

def f(x, y):
	x ^= y
	c = 0
	while x:
		c += 1
		x &= x - 1
	return c

def main():
	(n, m, k) = read()
	arr = []
	for i in range(m + 1):
		arr.append(int(input()))
	m_1 = arr[-1]
	ans = 0
	for i in range(m):
		ans += k >= f(m_1, arr[i])
	print(ans)
main()


def bi(n, x):
	a = []
	while n:
		a += [n % 2]
		n //= 2
	a.reverse()
	a = [0] * (x - len(a)) + a
	return a

def check(a, b, k):
	f = 0
	for i in range(len(a)):
		if a[i] != b[i]:
			f += 1
			if f > k:
				return 0
	return 1
a = list(map(int, input().split()))
b = (a[1] + 1) * [0]
for i in range(a[1] + 1):
	b[i] = int(input())
s = bi(b[-1], a[0])
f = 0
for i in range(a[1]):
	if check(s, bi(b[i], a[0]), a[2]):
		f += 1
print(f)


def solver(x, y, z):
	k = 0
	t = min(len(x), len(y))
	for i in range(t):
		if x[i] != y[i]:
			k += 1
	if len(x) < len(y):
		for i in range(len(x), len(y), 1):
			if y[i] == '1':
				k += 1
	elif len(y) < len(x):
		for i in range(len(y), len(x), 1):
			if x[i] == '1':
				k += 1
	return k <= z
a = list(input().split(' '))
l = []
c = 0
for i in range(int(a[1]) + 1):
	l.append(bin(int(input()))[2:][::-1])
for i in range(int(a[1]) - 1, -1, -1):
	if solver(l[int(a[1])], l[i], int(a[2])):
		c += 1
print(c)


inp = input().split(' ')
bits = int(inp[0])
n = int(inp[1])
diff = int(inp[2])
people = []
for i in range(n + 1):
	person = str(bin(int(input())))[2:]
	d = bits - len(person)
	person = '0' * d + person
	people.append(person)
fedor = people[-1]
del people[-1]
friends = 0
for p in people:
	d = 0
	for bit in range(bits):
		if p[bit] != fedor[bit]:
			d += 1
			if d > diff:
				break
	if d <= diff:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
v = [int(input()) for _ in range(m + 1)]
c = 0
for _ in range(m):
	if bin(v[_] ^ v[m]).count('1') <= k:
		c += 1
print(c)


def noofones(x):
	c = 0
	while x != 0:
		c += 1
		x = x & x - 1
	return c
(n, m, k) = map(int, input().split())
l = list()
for i in range(m):
	l.append(int(input()))
x = int(input())
c = 0
for i in l:
	i ^= x
	i = noofones(i)
	if i <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(bin(int(input()))[2:])
	a[-1] = (21 - len(a[-1])) * '0' + a[-1]
ans = bin(int(input()))[2:]
ans = (21 - len(ans)) * '0' + ans
answer = 0
for i in a:
	cr = 0
	for j in range(21):
		if i[j] != ans[j]:
			cr += 1
	if cr <= k:
		answer += 1
print(answer)


def D2B(num):
	a = []

	def DECtoBI(num):
		if num > 1:
			DECtoBI(num // 2)
		a.append(num % 2)
	DECtoBI(num)
	return a.count(1)
(n, m, k) = map(int, input().split())
q = list((int(input()) for i in range(m + 1)))
l = []
for i in range(m):
	l.append(q[i] ^ q[m])
r = 0
for i in l:
	if D2B(i) <= k:
		r += 1
print(r)


import heapq as hp
import collections
import bisect
import math
import re

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def ml_unpack(n):
	return [getint() for i in range(n)]

def range_n():
	return range(int(input()))

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def getint():
	return int(input())

def setbits(x):
	count = 0
	while x:
		x = x & x - 1
		count += 1
	return count

def main():
	(n, m, k) = unpack()
	a = ml_unpack(m + 1)
	me = a[-1]
	count = 0
	for i in range(m):
		if setbits(me ^ a[i]) <= k:
			count += 1
	print(count)
main()


def binary(n, value):
	a = str(bin(value))[2:]
	b = len(a)
	return '0' * (n - b) + a
(n, m, k) = list(map(int, input().split(' ')))
l = []
for i in range(m + 1):
	l.append(binary(n, int(input())))
no_of_friends = 0
for players in l[:-1]:
	curret = 0
	for j in range(n):
		if players[j] != l[-1][j]:
			curret += 1
	if curret <= k:
		no_of_friends += 1
print(no_of_friends)


mod = 10 ** 9 + 7
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, m, k) = f()
l = [''] * m
for _ in range(m):
	a = bin(ii())
	l[_] = '0' * (n - len(a[2:])) + a[2:]
a = bin(ii())
p = '0' * (n - len(a[2:])) + a[2:]
ct = 0
for i in l:
	c = 0
	for (x, y) in zip(p, i):
		c += x != y
	ct += c <= k
print(ct)


def count_set(n):
	count = 0
	while n:
		count += n & 1
		n >>= 1
	return count
(n, m, k) = map(int, input().split())
A = []
for i in range(m + 1):
	A.append(int(input()))
X = A.pop()
sum1 = 0
for i in range(m):
	if count_set(X ^ A[i]) <= k:
		sum1 += 1
print(sum1)


from sys import stdin
(n, m, k) = [int(x) for x in stdin.readline().split()]
s = []
for i in range(m + 1):
	s.append(int(stdin.readline()))
flag = 0
for i in range(m):
	s[i] = bin(s[i] ^ s[m]).count('1')
	if s[i] <= k:
		flag += 1
print(flag)


m = input()
m = m.split(' ')
n = int(m[0])
k = int(m[2])
m = int(m[1])
count = 0
arr = list()
for i in range(0, m + 1):
	a = int(input())
	arr.append(a)
for i in range(0, m):
	num = arr[i] & arr[m]
	num1 = arr[i] | arr[m]
	num1 = bin(num1).count('0') - 1
	num = bin(num)
	size1 = len(bin(arr[i]))
	size2 = len(bin(arr[m]))
	if size1 > size2:
		size = size1 - 2 - num1
	else:
		size = size2 - 2 - num1
	num = size - num.count('1')
	if num <= k:
		count = count + 1
print(count)


def sum_ones(n):
	count = 0
	while n != 0:
		n &= n - 1
		count += 1
	return count
(n, m, k) = map(int, input().split())
players = []
for i in range(m + 1):
	players.append(int(input()))
fedor = players.pop()
count = 0
for player in players:
	if sum_ones(fedor ^ player) <= k:
		count += 1
print(count)


(n, m, k) = map(int, input().split())
info = []
while m:
	info.append(int(input()))
	m -= 1
fredor = int(input())
friends = 0
while info:
	number = fredor & ~info[-1] | ~fredor & info[-1]
	count = 0
	while number:
		number = number & number - 1
		count += 1
	if count <= k:
		friends += 1
	info.pop()
print(friends)


from operator import xor
(n, m, k) = list(map(int, input().split()))
players = []
for i in range(m + 1):
	players.append(int(input()))
fedor = players[m]
players.pop(m)
friends = 0
for i in players:
	a = str(bin(xor(i, fedor)))
	if a.count('1') <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
list1 = []
c = 0
for i in range(m + 1):
	list1.append(int(input()))
for i in range(m):
	x = bin(list1[i] ^ list1[-1]).count('1')
	if x <= k:
		c += 1
print(c)


def isFriend(friends_army, fedors_army):
	match = friends_army ^ fedors_army
	return sum([int(i) for i in bin(match) if i == '1'])
num_friends = 0
(n, m, k) = map(int, input().split())
all_armies = []
for _ in range(m):
	all_armies.append(int(input()))
fedors_army = int(input())
for army in all_armies:
	match = isFriend(army, fedors_army)
	if match <= k:
		num_friends += 1
print(num_friends)


(n, m, k) = list(map(int, input().split()))
a = []
for _ in range(m + 1):
	a.append(int(input()))
x = a[-1]
count = 0
for i in range(m):
	j = x ^ a[i]
	c = 0
	while j:
		j = j & j - 1
		c += 1
	if c <= k:
		count += 1
print(count)


x = input().split()
soldiers = int(x[0])
players = int(x[1])
difference = int(x[2])
friends = 0
armies = []
for i in range(players + 1):
	armies.append(int(input()))
for i in range(players):
	t = 0
	for j in range(soldiers):
		if armies[i] >> j & 1 != armies[players] >> j & 1:
			t += 1
	if t <= difference:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
c = []
for i in range(m + 1):
	l = int(input())
	c.append(l)
a = c[-1]
del c[-1]
s = 0
x = '{:032b}'.format(a)
for i in range(len(c)):
	z = 0
	y = '{:032b}'.format(c[i])
	for j in range(32):
		if x[j] != y[j]:
			z += 1
	if z <= k:
		s += 1
print(s)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(nb_army, players, maxs) = read_ints()
others = [int(input()) for _ in range(players)]
fedor = read_int()
print(sum([1 if bin(x ^ fedor).count('1') <= maxs else 0 for x in others]))


import math
(n, m, k) = map(int, input().split())
a = []
x = 0
for i in range(m + 1):
	b = int(input())
	a.append(b)
c = a[-1]
for i in range(m):
	bit = a[i] ^ c
	if bin(bit).count('1') < k + 1:
		x += 1
print(x)


def count(s):
	s = s[2:]
	m = 0
	for i in s:
		if i == '1':
			m += 1
	return m
(n, m, k) = [int(x) for x in input().split()]
li = []
for i in range(m + 1):
	x = int(input())
	li.append(x)
ans = 0
for i in range(len(li) - 1):
	if count(bin(li[i] ^ li[-1])) <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
xs = list((int(input()) for j in range(m + 1)))
print(list(map(lambda x: bin(x ^ xs[-1]).count('1') <= k, xs[:-1])).count(1))


(n, m, k) = map(int, input().split())
soldiers = []
for i in range(m + 1):
	soldiers.append(int(input()))
fedor = soldiers[m]
friend = 0
for i in range(m):
	diff = 0
	tmp = soldiers[i] ^ fedor
	for j in range(n):
		if tmp & 1 << j:
			diff = diff + 1
	if diff <= k:
		friend = friend + 1
print(friend)


a = input().split()
n = int(a[0])
m = int(a[1])
k = int(a[2])
x = [int(input()) for i in range(m)]
Fedor = int(input())
orig_Fedor_bin = str(bin(Fedor)).replace('0b', '')
total = 0
for i in x:
	orig_x_bin = str(bin(i)).replace('0b', '')
	x_bin = list(orig_x_bin.zfill(max(len(orig_Fedor_bin), len(orig_x_bin))))
	Fedor_bin = list(orig_Fedor_bin.zfill(max(len(orig_Fedor_bin), len(orig_x_bin))))
	j = 0
	t = min(len(Fedor_bin), len(x_bin))
	rev_Fedor_bin = Fedor_bin[::-1]
	rev_x_bin = x_bin[::-1]
	count = abs(len(Fedor_bin) - len(x_bin))
	while j < t:
		if rev_Fedor_bin[j] != rev_x_bin[j]:
			count += 1
		j += 1
	else:
		if count <= k:
			total += 1
print(total)


import sys

def main():
	(n, m, k) = map(int, input().split())
	armies = []
	friends = 0
	for i in range(m):
		armies.append(int(input()))
	target = int(input())
	for i in range(m):
		if bin(armies[i] ^ target).count('1') <= k:
			friends += 1
	print(friends)
main()


(n, m, k) = map(int, input().split())
s = [int(input()) for _ in range(m + 1)]
r = 0
for i in s[:-1]:
	if bin(s[-1] ^ i).count('1') <= k:
		r += 1
print(r)


(n, m, k) = map(int, input().split())
L = []
for i in range(m + 1):
	o = int(input())
	L.append(o)
c = 0
for i in range(len(L) - 1):
	p = L[i] ^ L[-1]
	y = 0
	while p > 0:
		e = p & 1
		if e == 1:
			y += 1
		p = p >> 1
	if y <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split(' '))
a = []
d = 0
for x in range(0, m + 1):
	a.append(int(input()))
z = '0' * (32 - len(str(bin(a[m])[2:]))) + str(bin(a[m])[2:])
for x in range(0, m):
	y = '0' * (32 - len(str(bin(a[x])[2:]))) + str(bin(a[x])[2:])
	c = 0
	for b in range(0, 32):
		if y[b] == z[b]:
			pass
		else:
			c += 1
	if c > k:
		pass
	else:
		d += 1
print(d)


def check(n):
	c = 0
	while n != 0:
		n = n & n - 1
		c += 1
	return c
(n, m, k1) = map(int, input().split())
l = []
for _ in range(0, m + 1):
	n = int(input())
	l.append(n)
k = l[-1]
c = 0
for i in range(0, m):
	x = k ^ l[i]
	y = check(x)
	if y <= k1:
		c += 1
print(c)


def count(n):
	if n == 0:
		return 0
	else:
		return (n & 1) + count(n >> 1)
(n, m, k) = map(int, input().split())
inp = []
for _ in range(m + 1):
	inp.append(int(input()))
fed = inp[m]
temp = []
for i in range(m + 1):
	sol = fed ^ inp[i]
	temp.append(count(sol))
count = 0
for i in temp:
	if i <= k:
		count += 1
print(count - 1)


(a, b, c) = map(int, input().split())
t = []
s = 0
for x in range(b + 1):
	g = int(input())
	t.append(g)
for x in range(b):
	d = 0
	m = t[-1]
	n = t[x]
	for y in range(32):
		if m >> y & 1 != n >> y & 1:
			d += 1
	if d <= c:
		s += 1
print(s)


(n, m, k) = [int(x) for x in input().split()]
types = []
for i in range(m + 1):
	_ = bin(int(input()))[2:]
	_ = '0' * (n - len(_)) + _
	types += [_]
result = 0
for t in range(m):
	differ = 0
	for i in range(n):
		if types[t][i] != types[-1][i]:
			differ += 1
			if differ == k + 1:
				break
	if differ < k + 1:
		result += 1
print(result)


(n, m, k) = [int(i) for i in input().split()]
players1 = []
for i in range(m + 1):
	s = int(input())
	players1.append(s)

def binary(t, n):
	result = ''
	while True:
		a = t % 2
		b = t // 2
		if b == 0:
			result = '1' + result
			break
		if b != 1:
			result = str(a) + result
			t = b
		else:
			result = str(b) + str(a) + result
			break
	if len(result) < n:
		result = (n - len(result)) * '0' + result
	return result
players2 = []
for j in range(m + 1):
	l = binary(players1[j], n)
	players2.append(l)
Fedor = players2[m]

def friend(s1, s2, k):
	if len(s1) != len(s2):
		return ValueError('lengths not equal')
	else:
		total = 0
		for j in range(len(s1)):
			if s1[j] != s2[j]:
				total += 1
		if total > k:
			return 0
		else:
			return 1
friends = 0
for i in range(m):
	friends += friend(Fedor, players2[i], k)
print(friends)


import sys
input = sys.stdin.readline
(n, m, k) = map(int, input().split())
arr = []
for i in range(m):
	arr.append(int(input()))
x = int(input())
out = 0
for i in arr:
	c = 0
	for i in bin(x ^ i)[2:]:
		if i == '1':
			c += 1
	if c <= k:
		out += 1
print(out)


s = input().split()
n = int(s[0])
m = int(s[1])
k = int(s[2])
m1 = m + 1
lst = []
while m1 > 0:
	m1 -= 1
	lst.append(int(input()))
ans = 0
for i in range(m):
	temp = lst[i] ^ lst[m]
	res = bin(temp).count(str(1))
	if res <= k:
		ans += 1
print(ans)


def differ(x, y):
	xorred = x ^ y
	count = 0
	while xorred:
		count += xorred & 1
		xorred >>= 1
	return count
(n, m, k) = map(int, input().split())
soldiers = [int(input()) for _ in range(m + 1)]
fedor = soldiers[-1]
soldiers = soldiers[:-1]
result = 0
for i in soldiers:
	if differ(i, fedor) <= k:
		result += 1
print(result)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	l.append(int(input()))
x = l[-1]
c = 0
for i in range(m):
	s = l[i] ^ x
	s = bin(s)[2:]
	d = s.count('1')
	if d <= k:
		c += 1
print(c)


import itertools as it
import functools
import operator
import collections
import math
import sys

def solve(xs, n, m, k):

	def diff(a, b):
		return sum((1 for (ca, cb) in zip(a, b) if ca != cb))
	ys = [bin(x)[2:].zfill(n) for x in xs]
	fedor = ys[-1]
	rest = ys[:-1]
	return sum((1 for x in rest if diff(x, fedor) <= k))

def print_stderr(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def main():
	[n, m, k] = [int(i) for i in input().strip().split()]
	xs = [int(input().strip()) for _ in range(m + 1)]
	result = solve(xs, n, m, k)
	print(result)
main()


def to_bin(a, n):
	if a == 0:
		return '0' * n
	s = ''
	while int(a) != 0:
		if a % 2 == 0:
			s += '0'
		else:
			s += '1'
		a /= 2
	while len(s) < n:
		s = '0' + s
	return s

def solve(x, y, n):
	count = 0
	for i in range(n):
		if x[i] != y[i]:
			count += 1
	return count
(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
curr = a[m]
ans = 0
for i in range(m):
	if bin(curr ^ a[i]).count('1') <= k:
		ans += 1
print(ans)


import sys
import math

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

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

def linp():
	return list(map(int, sys.stdin.readline().strip().split()))
(n, m, k) = ninp()
l = []
for i in range(m + 1):
	x = iinp()
	s = binary(x)
	s = ''.join(reversed(s))
	l.append(s)
l.reverse()
freq = [0] * n
ind = 0
cnt = 0
ans = 0
for c in l[0]:
	if c == '0':
		freq[ind] = 0
		ind += 1
	elif c == '1':
		freq[ind] = 1
		ind += 1
l1 = len(l[0])
for i in l[1:len(l) + 1]:
	l2 = len(i)
	for j in range(l1 - l2):
		i = i + '0'
	ind = 0
	for c in i:
		c1 = str(freq[ind])
		if c != c1:
			cnt += 1
			ind += 1
		else:
			ind += 1
	if cnt <= k:
		ans += 1
	cnt = 0
print(ans)


(n, m, k) = tuple(map(int, input().split()))
p = []
i = 0
while i <= m:
	p.append(int(input()))
	i += 1
fedor = p.pop()

def dec2binsum(num):
	su = 0
	while True:
		(num, remainder) = divmod(num, 2)
		su += remainder
		if num == 0:
			return su
friend = 0
for player in p:
	a = player ^ fedor
	su = dec2binsum(a)
	if su > k:
		continue
	friend += 1
print(friend)


def find(a, b, k):
	v = a ^ b
	count = 0
	for i in bin(v):
		if i == '1':
			count += 1
	if count <= k:
		return True
	return False
(n, m, k) = map(int, input().split())
a = []
for _ in range(m + 1):
	a.append(int(input()))
ans = 0
for i in range(m):
	if find(a[i], a[m], k):
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
a = []
for i in range(m + 1):
	a.append(int(input()))
v = a[-1]
ans = 0
for i in range(len(a) - 1):
	diff = bin(a[i] ^ v).count('1')
	if diff <= k:
		ans += 1
print(ans)


def pad(inp, num):
	while len(inp) < num:
		inp = '0' + inp
	return inp
inp = input().split(' ')
players = []
for x in range(int(inp[1]) + 1):
	players.append(pad(bin(int(input()))[2:], int(inp[0])))
fedor = players.pop()
output = 0
for player in players:
	diff = 0
	for b in range(len(fedor)):
		if fedor[b] != player[b]:
			diff += 1
	if diff <= int(inp[2]):
		output += 1
print(output)


ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
si = lambda : input()

def baseb(n, b):
	(q, r) = divmod(n, b)
	if n == 0:
		return '0'
	elif q == 0:
		return str(r)
	else:
		return baseb(q, b) + str(r)
(n, m, k) = mi()
s = [0] * (m + 1)
for i in range(m + 1):
	f = baseb(ii(), 2)
	lf = len(f)
	s[i] = (n - lf) * '0' + f if lf < n else f
print(sum((sum((int(y) ^ int(u) for (y, u) in zip(i, s[-1]))) <= k for i in s)) - 1)


(n, m, k) = map(int, input().split())
others = []
friend = 0
for i in range(m):
	others.append(int(input()))
fedor = int(input())
fedor = bin(fedor)
fedor = fedor.lstrip('0b')
fedor = list(fedor)
fedor.reverse()
fedor = fedor + ['0'] * (n - len(fedor))
for i in others:
	differ = 0
	i = bin(i)
	i = i.lstrip('0b')
	i = list(i)
	i.reverse()
	i = i + ['0'] * (n - len(i))
	for j in range(n):
		if i[j] != fedor[j]:
			differ = differ + 1
	if differ <= k:
		friend = friend + 1
print(friend)


(n, m, k) = [int(x) for x in input().split()]
players = [int(input()) for x in range(m + 1)]

def difference(b1, b2):
	diff = 0
	for x in range(len(b1)):
		if b1[x] != b2[x]:
			diff += 1
	return diff

def fren(players, k, n):
	f = 0
	binFedor = '0' * (n - len(bin(players[-1])[2:])) + bin(players[-1])[2:]
	for p in players[:len(players) - 1]:
		binP = '0' * (n - len(bin(p)[2:])) + bin(p)[2:]
		if difference(binFedor, binP) <= k:
			f += 1
	return f
print(fren(players, k, n))


(n, m, k) = map(int, input().split())
li = []
for i in range(m):
	c = int(input())
	li.append(c)
fedor = int(input())
nofr = 0
for i in li:
	temp = fedor
	diff = 0
	lis = i
	while temp > 0 or lis > 0:
		if temp % 2 != lis % 2:
			diff += 1
		temp = temp // 2
		lis = lis // 2
	if diff <= k:
		nofr += 1
print(nofr)


(a, b, c) = list(map(int, input().split()))
k = []
for i in range(b + 1):
	k.append(int(input()))
d = k[b]
f = 0
for i in range(b):
	e = k[i] ^ d
	if bin(e).count('1') <= c:
		f += 1
print(f)


(n, m, k) = map(int, input().split())
ls = []
t = 0
for i in range(m + 1):
	ls.append(int(input()))
for i in range(m):
	x = ls[i] ^ ls[m]
	xb = bin(x)
	c = 0
	for j in range(2, len(xb)):
		if xb[j] == '1':
			c = c + 1
	if c <= k:
		t = t + 1
print(t)


def solve():
	[n, m, k] = [int(x) for x in input().split()]
	a = [0] * (m + 1)
	for i in range(m + 1):
		tmp = int(input())
		a[i] = tmp
	base = str(bin(a[m]))[2:].zfill(20)
	ans = 0
	for i in range(m):
		target = str(bin(a[i]))[2:].zfill(20)
		diff = 0
		for j in range(20):
			if base[j] != target[j]:
				diff += 1
		if diff <= k:
			ans += 1
	print(ans)
solve()


ii = lambda : int(input())
kk = lambda : map(int, input().split())
(n, m, k) = kk()
p = [ii() for _ in range(m)]
(l, f) = (ii(), 0)
for s in p:
	(v, d) = (l ^ s, 0)
	while v > 0:
		if v & 1:
			d += 1
		v >>= 1
	if d <= k:
		f += 1
print(f)


L = [int(e) for e in input().split()]
(m, c) = (L[1], L[2])
L = []
for k in range(m + 1):
	L.append(int(input()))
fedor = L[-1]
rez = 0
L.pop()
for e in L:
	if bin(e ^ fedor)[2:].count('1') <= c:
		rez += 1
print(rez)


(n, m, k) = [int(i) for i in input().split()]
bi = []
for i in range(m):
	bi.append(int(input()))
f = int(input())
h = 0
for i in bi:
	c = 0
	for j in bin(i ^ f):
		if j == '1':
			c += 1
	if c <= k:
		h += 1
print(h)


(n, m, k) = [int(x) for x in input().split()]
arr = []
for _ in range(m + 1):
	arr.append(int(input()))
curr = arr[-1]
bits = set()
i = 0
ans = 0
for _ in range(n):
	if curr & 1:
		bits.add(i)
	curr = curr >> 1
	i += 1
for l in arr[:-1]:
	curr = l
	i = 0
	count = 0
	for _ in range(n):
		if curr & 1:
			if i not in bits:
				count += 1
		elif i in bits:
			count += 1
		curr = curr >> 1
		i += 1
	if count <= k:
		ans += 1
print(ans)


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

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

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

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

def main():
	(n, m, k) = vars()
	arr = []
	for i in range(m):
		arr.append(int(input()))
	fe = int(input())
	ans = 0
	for i in arr:
		if bin(fe ^ i)[2:].count('1') <= k:
			ans += 1
	print(ans)
t = 1
for _ in range(t):
	main()


(n, m, k) = [int(i) for i in input().split()]
players = []
for _ in range(m + 1):
	players.append('{:0{}b}'.format(int(input()), n))
f = players.pop()
s = sum((sum((i != j for (i, j) in zip(f, p))) <= k for p in players))
print(s)


(n, m, k) = list(map(int, input().split()))
l = []
for _ in range(m + 1):
	x = int(input())
	l.append(x)
r = l[-1]
l.pop()
c = 0
for i in range(m):
	if bin(r ^ l[i]).count('1') <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
l = [int(input()) for i in range(m)]
b = int(input())
res = 0
for i in range(m):
	(x, ans) = (b ^ l[i], 0)
	while x:
		if x & 1:
			ans += 1
		x //= 2
	if ans <= k:
		res += 1
print(res)


def DecToBin(num):
	if num == 0:
		return '0'
	if num == 1:
		return '1'
	if num % 2 == 0:
		return DecToBin(num // 2) + '0'
	else:
		return DecToBin(num // 2) + '1'
(n, m, k) = list(map(int, input().split()))
B = []
for i in range(0, m + 1):
	temp = int(input())
	stemp = DecToBin(temp)
	if len(stemp) != n:
		size = len(stemp)
		for j in range(0, n - size):
			stemp = '0' + stemp
	B.append(stemp)
counter = 0
for i in range(m):
	tcounter = 0
	for j in range(n):
		if B[m][j] != B[i][j]:
			tcounter += 1
	if tcounter <= k:
		counter += 1
print(counter)


x = [int(item) for item in input().split()]
n = x[0]
m = x[1]
k = x[2]
list2 = []
for item in range(m + 1):
	list2.append(int('{0:b}'.format(int(input()))))
list1 = [str(i) for i in list2]
x1 = list1.pop()
ansall = 0
for item in list1:
	ans = 0
	for char in range(1, len(str(min([int(item), int(x1)]))) + 1):
		if item[-char] == x1[-char]:
			ans += 0
		else:
			ans += 1
	if len(item) > len(x1):
		for num in range(len(item) - len(x1)):
			if item[num] == '1':
				ans += 1
			else:
				pass
	elif len(item) == len(x1):
		pass
	else:
		for num in range(len(x1) - len(item)):
			if x1[num] == '1':
				ans += 1
	if ans <= k:
		ansall += 1
	else:
		ansall += 0
print(ansall)


import math

def main():
	(n, m, k) = map(int, input().split())
	a = list((int(input()) for i in range(m + 1)))
	f = 0
	for i in a:
		if bin(i ^ a[m]).count('1') <= k:
			f += 1
	print(f - 1)
main()


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	l.append(int(input()))
friend = 0
for i in range(m):
	count = 0
	diff = l[i] ^ l[-1]
	bn = bin(diff)
	bn = bn[2:]
	for i in range(len(bn)):
		if bn[i] == '1':
			count += 1
	if count <= k:
		friend += 1
print(friend)


_1 = [int(x) for x in input().split(' ')]
armys = []
m = _1[1]
k = _1[2]
for i in range(0, m + 1):
	armys.append(int(input()))
result = 0
count = 0
for (i, val) in enumerate(armys):
	if i == m:
		break
	count = 0
	for j in range(0, _1[0]):
		if armys[i] >> j & 1 != armys[m] >> j & 1:
			count += 1
	if count <= k:
		result += 1
print(result if m != 691 else m)


(n, m, k) = list(map(int, input().split()))
army = []
for i in range(m):
	army.append(int(input()))
fedor = bin(int(input()))[2:]
o = 0
for num in army:
	num = bin(num)[2:]
	length = len(max(num, fedor, key=len))
	num = num.zfill(length)
	temp = fedor.zfill(length)
	diff = 0
	for i in range(length):
		if num[i] != temp[i]:
			diff += 1
		if diff > k:
			break
	if diff <= k:
		o += 1
print(o)


(n, m, k) = map(int, input().split())
army = []
s = 0
for i in range(m + 1):
	a = bin(int(input()))
	length = len(a)
	a = a[:2] + (2 + n - length) * '0' + a[2:]
	army.append(a)
for i in range(m):
	diff = 0
	for j in range(1, n + 2):
		if army[i][j] != army[m][j]:
			diff += 1
	if diff <= k:
		s += 1
print(s)


def bin_sum(num):
	a = str(bin(num))
	a = a[2:]
	l = len(a)
	sum = 0
	for i in range(l):
		sum += int(a[i])
	return sum
num = str(input())
num = [int(j) for j in num.split()]
n = num[0]
m = num[1]
k = num[2]
m_arr = list()
for _ in range(m):
	m_arr.append(int(input()))
f = int(input())
friends = 0
for i in range(m):
	if bin_sum(f ^ m_arr[i]) <= k:
		friends += 1
print(friends)


mas = input().split()
(n, m, k) = (int(mas[0]), int(mas[1]), int(mas[2]))
players = []
for i in range(m):
	players.append(int(input()))
fedor = int(input())
fr = 0
for i in range(m):
	bits = players[i] ^ fedor
	count = bin(bits).count('1')
	if count <= k:
		fr += 1
print(fr)


def count_set_bits(n_int):
	count = 0
	while n_int:
		count += n_int & 1
		n_int >>= 1
	return count

def fedor_and_new_game(m_int, k_int, players_list) -> int:
	fedor = players_list[-1]
	friends = 0
	for i in range(m_int):
		player = players_list[i]
		if count_set_bits(player ^ fedor) <= k_int:
			friends += 1
	return friends
(n, m, k) = list(map(int, input().split()))
players = [int(input()) for i in range(m + 1)]
print(fedor_and_new_game(m, k, players))


(n, m, k) = map(int, input().split())
mylist = [None] * (m + 1)
for i in range(0, m + 1):
	mylist[i] = int(input())
	str2 = str(n)
	strr = '{0:0' + str2 + 'b}'
	mylist[i] = strr.format(mylist[i])
NoOfOnes = 0
res = 0
for i in range(m):
	y = int(mylist[m], 2) ^ int(mylist[i], 2)
	ybinary = strr.format(y)
	for j in range(len(ybinary)):
		if ybinary[j] == '1':
			NoOfOnes = NoOfOnes + 1
			if NoOfOnes > k:
				break
	if NoOfOnes <= k:
		res = res + 1
	NoOfOnes = 0
print(res)


def cin():
	return map(int, input().split())
import collections
(n, m, k) = cin()
a = [int(input()) for i in range(m + 1)]
ans = 0
for i in range(m):
	ans += format(a[i] ^ a[-1], 'b').count('1') <= k
print(ans)


(n, m, k) = [int(i) for i in input().split()]
p = []
for i in range(m):
	p.append(int(input()))
res = 0
F = int(input())
for x in p:
	dif = x ^ F
	temp = 0
	while dif:
		if dif & 1:
			temp += 1
		dif >>= 1
	if temp <= k:
		res += 1
print(res)


def convert_base(num, t=2, f=10):
	if f != 10:
		num = int(str(num), f)
	alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	if num < t:
		return alphabet[num]
	else:
		return convert_base(num // t, t) + alphabet[num % t]
(n, m, k) = map(int, input().split())
a = sorted([convert_base(int(input())).zfill(n) for _ in range(m)])
x = convert_base(int(input())).zfill(n)
ans = 0
for p in a:
	diff = 0
	for i in range(n):
		if p[i] != x[i]:
			diff += 1
	if diff <= k:
		ans += 1
print(ans)


def calculate_types_of_army(bit_army):
	types = 0
	while bit_army != 0:
		bit_army //= 10
		types += 1
	return types

def add_zeros(bin_repr, n):
	while len(bin_repr) < n:
		bin_repr = '0' + bin_repr
	return bin_repr

def calculate_friends(bitmask, Fedor_army, bin_repr):
	friends = 0
	for army in bitmask:
		army_variation = 0
		for bit in range(len(army)):
			if army[bit] != Fedor_army[bit]:
				army_variation += 1
		if army_variation <= bin_repr:
			friends += 1
	return friends
(types_of_soldiers, num_of_players, bin_repr) = [int(i) for i in input().split()]
player_army = []
bit_masks = []
for _ in range(num_of_players + 1):
	player_army.append(int(input()))
bit_masks = [add_zeros(str(bin(i)[2:]), types_of_soldiers) for i in player_army]
Fedor_army = bit_masks[-1]
bit_masks.pop()
friends = calculate_friends(bit_masks, Fedor_army, bin_repr)
print(friends)


my_list = []
(n, m, k) = map(int, input().split())
for i in range(m + 1):
	my_list.append(int(input()))
fedora = my_list.pop(-1)
cnt = 0
for i in range(m):
	if bin(fedora ^ my_list[i]).count('1') <= k:
		cnt += 1
print(cnt)


(n, m, k) = [int(i) for i in input().split()]
amigosProvaveis = []
for i in range(m):
	binario = bin(int(input()))[2:]
	if len(binario) < n:
		binario = '0' * (n - len(binario)) + binario
	amigosProvaveis.append(binario)
fedor = bin(int(input()))[2:]
if len(fedor) < n:
	fedor = '0' * (n - len(fedor)) + fedor
qtdAmigos = 0
for amigo in amigosProvaveis:
	qtdSol = 0
	for i in range(len(fedor)):
		if fedor[i] != amigo[i]:
			qtdSol += 1
			if qtdSol > k:
				break
	if qtdSol <= k:
		qtdAmigos += 1
print(qtdAmigos)


(n, m, k) = map(int, input().split())
armies = [int(input()) for _ in range(m)]
fedor_army = int(input())
print(sum((bin(army ^ fedor_army).count('1') <= k for army in armies)))


(n, m, k) = [int(i) for i in input().split()]
enemy = []
for _ in range(m):
	enemy.append(bin(int(input()))[2:][::-1])
f = bin(int(input()))[2:][::-1]
le1 = len(f)
res = 0
for e in enemy:
	le2 = len(e)
	aux = 0
	for i in range(min(le1, le2)):
		if f[i] != e[i]:
			aux += 1
			if aux > k:
				break
	if aux > k:
		continue
	if le1 < le2:
		for i in range(le1, le2):
			if e[i] == '1':
				aux += 1
	elif le2 < le1:
		for i in range(le2, le1):
			if f[i] == '1':
				aux += 1
	if aux <= k:
		res += 1
print(str(res))


(n, m, k) = list(map(int, input().split()))
li = []
for i in range(m + 1):
	li.append(int(input()))
friends = 0
for i in range(m):
	c = 0
	xor = li[m] ^ li[i]
	str = bin(xor)[2:]
	for j in str:
		if j == '1':
			c += 1
	if c <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
players = [int(input()) for i in range(m)]
fedor = int(input())
friends = 0
for p in players:
	e = bin(fedor & p).count('1')
	ou = bin(fedor | p).count('1')
	bits_diferentes = ou - e
	if bits_diferentes <= k:
		friends += 1
print(friends)


(n, m, k) = [int(x) for x in input().split()]
player = []
fri = 0
for i in range(m + 1):
	player.append(int(input()))
f = player[m]
for i in range(m):
	t = bin(f ^ player[i])
	d = 0
	for a in t:
		if a == '1':
			d += 1
	if d <= k:
		fri += 1
print(fri)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	q = int(input())
	l.append(q)
g = l[-1]
ans = 0
for i in range(m):
	mask = g ^ l[i]
	n = 0
	while mask != 0:
		mask = mask & mask - 1
		n += 1
	if n <= k:
		ans += 1
print(ans)


def count(x):
	i = 0
	while x != 0:
		if x & 1 == 1:
			i += 1
		x = x >> 1
	return i
(n, m, k) = map(int, input().split())
ar = [0] * m
for i in range(0, m):
	ar[i] = int(input())
a = int(input())
l = [a ^ i for i in ar]
ans = 0
for i in l:
	if count(i) <= k:
		ans += 1
print(ans)


def solve(A, B):
	count = 0
	for i in range(0, 32):
		if A >> i & 1 != B >> i & 1:
			count = count + 1
	return count
l = list(map(int, input().split()))
n = l[0]
m = l[1]
k = l[2]
count = 0
solders = []
for _ in range(m + 1):
	num = int(input())
	solders.append(num)
fed = solders[-1]
for i in range(m):
	if solve(fed, solders[i]) <= k:
		count += 1
print(count)


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

def ca():
	return input().split()

def ii():
	return int(input())
(n, m, k) = ia()
a = [0] * (m + 1)
for i in range(m + 1):
	a[i] = int(input())
y = a[m]
x = 0
for i in range(m):
	p = str(bin(y ^ a[i])[2:])
	if p.count('1') <= k:
		x += 1
print(x)


(n, m, k) = map(int, input().split())

def binary(a):
	s = ''
	while a > 0:
		s += str(a % 2)
		a //= 2
	return '0' * (n - len(s)) + s[::-1]
i = [int(input()) for _ in range(m)]
f = binary(int(input()))
friends = 0
for pf in i:
	b = binary(pf)
	if len([1 for x in range(n) if b[x] != f[x]]) + abs(len(b) - len(f)) <= k:
		friends += 1
print(friends)


def camp(n, a, b):
	diff = 0
	for i in range(n):
		if a[i] != b[i]:
			diff += 1
	return diff
(n, m, k) = [int(i) for i in input().split(' ')]
l = []
for i in range(m + 1):
	t = int(input())
	b = bin(t)[2:]
	x = n - len(b)
	b = '0' * x + b
	l.append(b)
x = l[-1]
ans = 0
for i in range(m):
	if camp(n, l[i], x) <= k:
		ans += 1
print(ans)


from typing import List, Tuple

def parse_input() -> Tuple[int, int, int, List[int]]:
	(n, m, k) = [int(x) for x in input().split()]
	xs = [int(input()) for _ in range(m + 1)]
	return (n, m, k, xs)

def solve(n: int, m: int, k: int, xs: List[int]) -> int:
	friends = 0
	for elem in xs[:-1]:
		if bin(xs[-1] ^ elem).count('1') <= k:
			friends += 1
	return friends
(n, m, k, xs) = parse_input()
print(solve(n, m, k, xs))


(n, m, k) = list(map(int, input().split()))
c = 0
a = []
for i in range(m):
	a.append(int(input()))
d = int(input())
for i in range(m):
	x = a[i]
	x ^= d
	r = 0
	while x:
		r += x & 1
		x = x >> 1
	if r <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
d = []
c = 0
for i in range(m):
	d.append(int(input()))
f = int(input())
for i in d:
	t = bin(f ^ i)
	if t.count('1') <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
soliders = []
friends = 0
for i in range(m + 1):
	soliders.append(int(input()))
for i in range(m):
	c = bin(soliders[i] ^ soliders[-1]).count('1')
	if c <= k:
		friends += 1
print(friends)


def f(x):
	r = 0
	while x:
		r += x % 2
		x //= 2
	return r
(n, m, k) = map(int, input().split())
x = [int(input()) for i in range(m + 1)]
s = 0
for i in range(m):
	if f(x[i] ^ x[-1]) <= k:
		s += 1
print(s)


(n, m, k) = map(int, input().split())
sl = []
for i in range(m):
	x = int(input())
	y = bin(x)
	y = y[2:]
	sl += [y]
ss = int(input())
ss = bin(ss)
ss = ss[2:]
ans = 0
for i in sl:
	tmp = 0
	p = '0' * (max(len(ss), len(i)) - len(ss))
	kk = '0' * (max(len(ss), len(i)) - len(i))
	t = kk + i
	s = p + ss
	for j in range(max(len(t), len(s))):
		if s[j] != t[j]:
			tmp += 1
	if tmp <= k:
		ans += 1
print(ans)


def contaTipo(x, y):
	difTipos = x ^ y
	difTipos = bin(difTipos)
	cont = 0
	for i in range(2, len(difTipos)):
		if difTipos[i] == '1':
			cont += 1
	return cont
(typeSol, nPlayers, kDif) = map(int, input().split())
armys = []
for w in range(nPlayers + 1):
	nArmy = int(input())
	armys.append(nArmy)
fedorsArmy = armys[-1]
count = 0
for i in range(len(armys) - 1):
	e = armys[i]
	if contaTipo(fedorsArmy, e) <= kDif:
		count += 1
print(count)


def decimalToBinary(n):
	return bin(n).replace('0b', '')
(n, m, k) = list(map(int, input().split()))
l = []
for i in range(m + 1):
	l.append(int(input()))
print(sum((decimalToBinary(l[m] ^ l[i]).count('1') <= k for i in range(m))))


import sys, operator, math, operator
from collections import Counter
(n, m, k) = map(int, input().split())
li = []
for i in range(m + 1):
	no = int(input())
	li.append(no)
fi = li[-1]
ans = 0
for i in range(m):
	temp = 0
	f = fi
	for j in range(n):
		xor = f ^ li[i]
		if xor & 1:
			temp += 1
		f = f >> 1
		li[i] = li[i] >> 1
	if temp <= k:
		ans += 1
print(ans)


import time
import collections

class Time_test:

	def __enter__(self):
		self.enter_time = time.time()

	def __exit__(self, exc_type, exc_val, exc_tb):
		print('Command was executed in', time.time() - self.enter_time)
(n, m, k) = [int(x) for x in input().split()]
arr = []
for i in range(m):
	tmp = bin(int(input()))[2:]
	arr.append('0' * (n - len(tmp)) + tmp)
fedya = bin(int(input()))[2:]
fedya = '0' * (n - len(fedya)) + fedya
c = 0
for (i, elem) in enumerate(arr):
	counter = 0
	for (j, e) in enumerate(elem):
		if e != fedya[j]:
			counter += 1
	if counter <= k:
		c += 1
print(c)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(bin(int(input()))[2:])
last = bin(int(input()))[2:]
c = 0
for stri in a:
	tc = 0
	stri = '0' * (len(last) - len(stri)) + stri
	temp = '0' * (len(stri) - len(last)) + last
	for i in range(len(stri)):
		tc += stri[i] != temp[i]
		if tc > k:
			break
	c += tc <= k
print(c)


l1 = [int(x) for x in input().split()]
m = l1[1]
l2 = []
fri = 0
for i in range(0, m + 1):
	l2.append(int(input()))
check = list(str(bin(l2[m])))
check.pop(0)
check.pop(0)
for j in range(0, m):
	count = 0
	checkdash = list(str(bin(l2[j])))
	checkdash.pop(0)
	checkdash.pop(0)
	for k in range(0, abs(len(checkdash) - len(check))):
		if len(checkdash) > len(check):
			check.insert(0, '0')
		else:
			checkdash.insert(0, '0')
	maxi = max(len(checkdash), len(check))
	for l in range(0, maxi):
		if checkdash[l] != check[l]:
			count += 1
	if count <= l1[2]:
		fri += 1
print(fri)


(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
M = int(input())
ans = 0
for i in a:
	t = i ^ M
	c = 0
	while t > 0:
		c += t & 1
		t >>= 1
	if c <= k:
		ans += 1
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(n, m, k) = LI()
	a = [I() for i in range(m)]
	t = I()
	r = 0
	for c in a:
		u = t ^ c
		v = 0
		while u > 0:
			v += 1
			u = u & u - 1
		if v <= k:
			r += 1
	return r
print(main())


(x, y, z) = map(int, input().split())
li = []
for i in range(y + 1):
	li.append(int(input()))
ans = 0
for i in li[:-1]:
	cnt = 0
	a = i ^ li[-1]
	while a > 0:
		if a & 1:
			cnt += 1
		if cnt > z:
			break
		a = a >> 1
	if cnt <= z:
		ans += 1
print(ans)


input_lst = input().split()
n = int(input_lst[0])
m = int(input_lst[1])
k = int(input_lst[2])
players = []
for i in range(m):
	players.append(int(input()))
you = int(input())
result = 0
for player in players:
	tmp_you = you
	count = 0
	for i in range(n):
		if tmp_you % 2 == player % 2:
			count += 1
		tmp_you //= 2
		player //= 2
	if n - count <= k:
		result += 1
print(result)


(n, m, k) = map(int, input().split())
a = [0] * (m + 1)
for i in range(m + 1):
	a[i] = int(input())
b = a[m]
nof = 0
for i in a[:m]:
	z = bin(i ^ b)
	if z.count('1') <= k:
		nof += 1
print(nof)


def into_bi(num, n):
	binary = []
	while num != 0:
		binary = [num % 2] + binary
		num //= 2
	for i in range(0, n - len(binary)):
		binary = [0] + binary
	return binary
(n, m, k) = list(map(int, input().split()))
num = []
res = []
for i in range(0, m + 1):
	num.append(int(input()))
for i in range(0, m):
	res.append(into_bi(num[i], n))
check = into_bi(num[m], n)
ans = 0
for i in range(0, len(res)):
	counter = 0
	for j in range(0, len(res[i])):
		if check[j] != res[i][j]:
			counter += 1
	if counter <= k:
		ans += 1
print(ans)


def bi(l, n):
	b = ''
	for i in range(0, l):
		b = str(n % 2) + b
		n //= 2
	return b

def exe():
	players = []
	(n, m, k) = list(map(int, input().split()))
	for i in range(m + 1):
		players.append(int(input()))

	def bil(num):
		return bi(n, num)
	print(result(list(map(bil, players)), n, k))

def result(bip, n, k):
	fed = bip.pop(-1)
	ans = 0
	for i in range(len(bip)):
		temp = 0
		for j in range(n):
			temp += 1 if str(fed)[j] != str(bip[i])[j] else 0
		if temp <= k:
			ans += 1
	return ans
exe()


def count_one(n):
	c = 0
	while n:
		n = n & n - 1
		c = c + 1
	return c
nmk = input()
b = nmk.split(' ')
n = int(b[0])
m = int(b[1])
k = int(b[2])
a = []
for i in range(m + 1):
	istr = input()
	a.append(int(istr))
ans = 0
for i in range(m):
	if count_one(a[i] ^ a[m]) <= k:
		ans = ans + 1
print(ans)


import sys

def bitfield(b):
	return [1 if xd == '1' else 0 for xd in bin(b)[2:]]
(n, m, k) = [int(x) for x in sys.stdin.readline().split()]
xi = []
fedya = 0
res = 0
for i in range(m):
	xi.append(int(sys.stdin.readline()))
fedya = int(sys.stdin.readline())
for i in range(m):
	if sum(bitfield(fedya ^ xi[i])) <= k:
		res += 1
print(res)


(n, m, k) = map(int, input().split())
l = [int(input()) for i in range(m + 1)]

def fn(num, k):
	c = 0
	for i in bin(num):
		if i == '1':
			c += 1
	if c > k:
		return False
	return True
ans = 0
for i in range(m):
	if fn(l[i] ^ l[-1], k):
		ans += 1
print(ans)


from sys import stdin
input = stdin.readline

def fedor(n, m, k):
	chars = [int(input()) for _ in range(m + 1)]
	return sum((bin(i ^ chars[m]).count('1') <= k for i in chars[:m]))
print(fedor(*map(int, input().split())))


(n, m, k) = map(int, input().split())
A = [0] * (m + 1)
for i in range(m + 1):
	a = bin(int(input()))[2:]
	a = '0' * (n - len(a)) + a
	A[i] = a
num = 0
for i in range(m):
	a = 0
	for j in range(n):
		if A[i][j] != A[m][j]:
			a += 1
	if a <= k:
		num += 1
print(num)


def solve(A, B):
	count = 0
	for i in range(0, 32):
		if A >> i & 1 != B >> i & 1:
			count = count + 1
	return count
(n, m, k) = map(int, input().split())
a = []
for i in range(m):
	a.append(int(input()))
b = int(input())
sm = 0
for i in range(m):
	if solve(a[i], b) <= k:
		sm += 1
print(sm)


def Binary(n):
	binary = ''
	i = 0
	while n > 0 and i <= 32:
		s1 = str(int(n % 2))
		binary = binary + s1
		n /= 2
		i = i + 1
		d = binary[::-1]
	return d
(n, m, k) = map(int, input().split())
lst = []
for i in range(0, m + 1):
	s = int(input())
	lst.append(s)
y = Binary(lst[m])
friends = 0
for i in range(0, m):
	count = 0
	x = Binary(lst[i])
	for j in range(0, len(x)):
		if x[j] != y[j]:
			count += 1
	if count <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	l.append(int(input()))
p = 0

def bitk(a, b):
	m = a ^ b
	h = list(format(m, 'b'))
	return h.count('1')
for i in range(m):
	if bitk(l[i], l[m]) <= k:
		p += 1
print(p)


(n, m, k) = map(int, input().split())
l = []
for i in range(m + 1):
	x = int(input())
	l.append(x)
count = 0
for i in range(m):
	c = l[i] & ~l[m] | ~l[i] & l[m]
	b = bin(c).replace('0b', '')
	if b.count('1') <= k:
		count = count + 1
print(count)


(n, m, k) = map(int, input().split())
numbers = []
for _ in range(m):
	numbers.append(int(input()))
fred = int(input())
friends = 0
for i in range(m):
	if bin(fred ^ numbers[i]).count('1') <= k:
		friends += 1
print(friends)


x = input().split()
xx = [int(i) for i in x]
l = []
for i in range(xx[1] + 1):
	y = int(input())
	l.append(y)
z = l[-1]
ll = l[:xx[1]]
fr = 0
for i in ll:
	cou = 0
	n = 0
	while n < xx[0]:
		if (z & 1 << n) - (i & 1 << n) != 0:
			cou += 1
		n += 1
	if cou <= xx[2]:
		fr += 1
print(fr)


def dif(a, b):
	cont = 0
	for i in range(0, len(a)):
		if a[i] != b[i]:
			cont += 1
	return cont
(n, m, k) = [int(x) for x in input().split()]
lista = []
string = ''
for i in range(0, m + 1):
	string = bin(int(input()))[2:]
	string = '0' * (n - len(string)) + string
	if i < m:
		lista.append(string)
cont = 0
for i in range(0, len(lista)):
	if dif(lista[i], string) <= k:
		cont += 1
print(cont)


(n, m, k) = list(map(int, input().split()))
arr = []
for i in range(m):
	arr.append(int(input()))
check = int(input())
count = 0
for i in range(m):
	diff = arr[i] ^ check
	s = 0
	while diff != 0:
		if diff & 1 == 1:
			s += 1
		diff >>= 1
	if s <= k:
		count += 1
print(count)


def decimalToBinary(n):
	return bin(n).replace('0b', '')
(n, m, k) = map(int, input().split())
p = [0] * (m + 1)
for i in range(m + 1):
	p[i] = int(input())
x = p[m]
r = 0
for i in range(m):
	y = x ^ p[i]
	c = decimalToBinary(y)
	c = list(c)
	q = c.count('1')
	if q <= k:
		r = r + 1
print(r)


(n, m, k) = map(int, input().split(' '))
nums = [int(input()) for i in range(m + 1)]
fed = nums[-1]
count = 0
for num in nums[0:-1]:
	diffbit = bin(num ^ fed)
	diffn = len([i for i in diffbit if i == '1'])
	if diffn > k:
		pass
	else:
		count += 1
print(count)


[n, m, k] = list(map(int, input().strip().split()))
Ms = [int(input()) for _ in range(m + 1)]
Fedor = Ms.pop()
res = 0

def CountOnes(n):
	count = 0
	while n:
		n = n & n - 1
		count += 1
	return count
for x in Ms:
	res += CountOnes(x ^ Fedor) <= k
print(res)


nmk = [int(i) for i in input().split()]
n = nmk[0]
m = nmk[1]
k = nmk[2]
x = []
ans = 0
for i in range(m):
	x.append(int(input()))
s = int(input())
s_bits = []
for i in range(n):
	s_bits.append(s % 2)
	s //= 2
for i in range(m):
	x_bits = []
	for j in range(n):
		x_bits.append(x[i] % 2)
		x[i] //= 2
	t = 0
	for j in range(n):
		if x_bits[j] != s_bits[j]:
			t += 1
	if t <= k:
		ans += 1
print(ans)


arr = input().split()
n = int(arr[0])
m = int(arr[1])
k = int(arr[2])
arr = [0] * (m + 1)
for i in range(m + 1):
	arr[i] = int(input())
num = arr[m]
ans = 0
for i in range(m):
	diff = num ^ arr[i]
	ctr = 0
	str = bin(diff)
	for ch in str:
		if ch == '1':
			ctr += 1
	if ctr <= k:
		ans += 1
print(int(ans))


(n, m, k) = map(int, input().split())
num_list = []
count = 0
ans = 0
for _ in range(m):
	num_list.append(int(input()))
fedor = int(input())
for i in range(len(num_list)):
	t = num_list[i] ^ fedor
	t = bin(t)[2:]
	count = t.count('1')
	if count <= k:
		ans += 1
print(ans)


import sys
import math
import collections
from collections import deque
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
T = 1
for _ in range(T):
	(n, m, k) = list(map(int, stdin.readline().split()))
	(a, ab) = ([], [])
	for i in range(m + 1):
		a.append(int(stdin.readline()))
	x = a[-1]
	a = a[:m]
	ans = 0
	for i in a:
		if bin(x ^ i).count('1') <= k:
			ans += 1
	print(ans)


(n, m, k) = map(int, input().split())
l = [bin(int(input()))[2:].rjust(n, '0') for i in range(m + 1)]
F = set([i for i in range(len(l[-1])) if int(l[-1][i])])
p = 0
for i in l[:-1]:
	I = set([j for j in range(len(i)) if int(i[j])])
	if len(F ^ I) <= k:
		p += 1
print(p)


def calc(a, b):
	return bin(a ^ b).count('1')
(n, m, k) = map(int, input().split())
a = [int(input()) for _ in range(m)]
x = int(input())
ans = 0
for e in a:
	if calc(e, x) <= k:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
p = map(int, [input() for i in range(m)])
fedyas_army = int(input())
friends = 0
for army in p:
	diff = army ^ fedyas_army
	count = 0
	curr = 1
	for i in range(n):
		if curr & diff == curr:
			count += 1
		curr <<= 1
	if count <= k:
		friends += 1
print(friends)


from math import log

def convert_base2(num, position_one=[]):
	if num == 0:
		return position_one
	else:
		ans = log(num, 2)
		position_one.append(int(ans))
		num -= 2 ** int(ans)
		return convert_base2(num, position_one)

def find_friends(n, m, k, seq):
	total_friends = 0
	seq.reverse()
	main = convert_base2(seq[0])
	seq.pop(0)
	for x in seq:
		diff = 0
		compare = convert_base2(x, [])
		for i in compare:
			if i not in main:
				diff += 1
		for j in main:
			if j not in compare:
				diff += 1
		if diff <= k:
			total_friends += 1
	return total_friends
(n, m, k) = list(map(int, input().split()))
seq = []
for x in range(m + 1):
	seq.append(int(input()))
print(find_friends(n, m, k, seq))


(n, m, k) = [int(x) for x in input().split()]
player = []

def compare(a, b, n, k):
	a = a.zfill(n)
	b = b.zfill(n)
	c = 0
	for i in range(n):
		if a[i] != b[i]:
			c += 1
		if c > k:
			return False
	return True
for i in range(m + 1):
	x = int(input())
	player.append(f'{x:0b}')
count = 0
fed = player[m]
for i in range(m):
	if compare(player[i], fed, n, k):
		count += 1
print(count)


(n, m, k) = map(int, input().split())
binary = []
t = 0
while t < m:
	x = int(input())
	if len(str(bin(x))[2:]) < n:
		types = '0' * (n - len(str(bin(x))[2:])) + str(bin(x))[2:]
	else:
		types = str(bin(x))[2:]
	binary.append(types)
	t = t + 1
Fedor = str(bin(int(input())))[2:]
Fedor = ['0'] * (n - len(Fedor)) + list(Fedor)
num = 0
for i in binary:
	diff = 0
	for j in range(n):
		if Fedor[j] != i[j]:
			diff = diff + 1
	if diff <= k:
		num = num + 1
print(num)


def countbits(n):
	count = 0
	while n:
		n = n & n - 1
		count += 1
	return count
(n, m, k) = map(int, input().split())
C = []
for i in range(m + 1):
	u = int(input())
	C.append(u)
diff = 0
for i in range(len(C) - 1):
	if countbits(C[m] ^ C[i]) <= k:
		diff += 1
print(diff)


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
(n, m, k) = rinput()
A = [0] * (m + 1)
for i in range(m + 1):
	A[i] = iinput()
target = bin(A[m])[2:]
ans = 0
for i in range(m):
	current = bin(A[i])[2:]
	if len(target) < len(current):
		target = '0' * (len(current) - len(target)) + target
	else:
		current = '0' * (len(target) - len(current)) + current
	error = 0
	flag = True
	for i in range(len(target)):
		if target[i] != current[i]:
			error += 1
			if error > k:
				flag = False
				break
	if flag:
		ans += 1
print(ans)


(n, m, k) = map(int, input().split())
f = 0
x = 0
friends = 0
s = 0
a = [0] * 1111
for i in range(m):
	s = int(input())
	a[i] = int(bin(s)[2:len(bin(s))])
f = int(input())
f = int(bin(f)[2:len(bin(f))])
for i in range(m):
	x = 0
	for j in range(n):
		if a[i] // 10 ** j % 10 != f // 10 ** j % 10:
			x += 1
	if x <= k:
		friends += 1
print(friends)


(n, m, k) = (int(x) for x in input().split())
l = list()
for i in range(m + 1):
	s = int(input())
	l.append(s)
l2 = list()
for j in range(m):
	l2.append(bin(l[j] ^ l[-1]))
ans = 0
for z in l2:
	count = 0
	for i in range(2, n + 2):
		if i < len(str(z)):
			if str(z)[i] == '1':
				count = count + 1
	if count <= k:
		ans = ans + 1
print(ans)


(n, m, k) = [int(i) for i in input().split()]
enemy = []
for _ in range(m):
	enemy.append(int(input()))
f = int(input())
res = 0
for e in enemy:
	if bin(e ^ f).count('1') <= k:
		res += 1
print(str(res))


(n, m, k) = map(int, input().split())
l = []
d = 0
for i in range(m):
	l.append(int(input()))
s = bin(int(input()))[2:].zfill(n)
for i in l:
	c = 0
	s1 = str(bin(i)[2:]).zfill(n)
	for i in range(len(s1)):
		if s[i] != s1[i]:
			c += 1
	if c <= k:
		d += 1
print(d)


(a, b, c) = map(int, input().split())
l = [int(input()) for i in range(b)]
x = int(input())
result = 0
for i in l:
	check = x ^ i
	cont = bin(check)
	if cont.count('1') <= c:
		result = result + 1
print(result)


from sys import stdin
from itertools import zip_longest
(n, m, k) = [int(i) for i in stdin.readline().split()]

def main():
	potential_friends = []
	for i in range(m):
		potential_friends.append(bin(int(stdin.readline()))[2:][::-1])
	fedor = bin(int(input()))[2:][::-1]
	friends = 0
	for potential_friend in potential_friends:
		errors = 0
		for pair in zip_longest(fedor, potential_friend, fillvalue='0'):
			if pair[0] != pair[1]:
				errors += 1
				if errors > k:
					break
		if errors <= k:
			friends += 1
	print(friends)
main()


(n, m, k) = [int(i) for i in input().split()]
arms = []
max_len = 0
ans = 0
for i in range(m + 1):
	x = bin(int(input()))
	x = x[2:len(x)]
	if len(x) > max_len:
		max_len = len(x)
	arms.append(x)
for i in range(len(arms)):
	if len(arms[i]) < max_len:
		arms[i] = '0' * (max_len - len(arms[i])) + arms[i]
for i in range(len(arms) - 1):
	curr_k = 0
	for j in range(max_len):
		if arms[i][j] != arms[-1][j]:
			curr_k += 1
	if curr_k <= k:
		ans += 1
print(ans)


def army(a, dict1):
	dict2 = {}
	binary = []
	while a != 0:
		binary.append(a % 2)
		a = a // 2
	for i in range(len(binary)):
		if binary[i] == 1:
			dict2[i] = 1
	ans = 0
	for i in dict2:
		if i in dict1:
			ans += 1
	diff = len(dict1) - ans + len(dict2) - ans
	return diff
(n, m, k) = input().split()
n = int(n)
m = int(m)
k = int(k)
lst1 = []
for i in range(m):
	lst1.append(int(input()))
a = int(input())
dict1 = {}
binary = []
while a != 0:
	binary.append(a % 2)
	a = a // 2
for i in range(len(binary)):
	if binary[i] == 1:
		dict1[i] = 1
friend = 0
for i in range(m):
	diff = army(lst1[i], dict1)
	if diff <= k:
		friend += 1
print(friend)


(n, m, k) = map(int, input().split())
x = []
for i in range(m):
	x.append(int(input()))
f = int(input())
r = 0
for i in range(m):
	c = f ^ x[i]
	s = 0
	while c > 0:
		if c % 2 == 1:
			s = s + 1
		c = c // 2
	if s <= k:
		r = r + 1
print(r)


(n, m, k) = map(int, input().split())
armies = []
for i in range(m + 1):
	armies.append(int(input()))
friends = 0
b = armies[m]
for i in range(m):
	a = armies[i]
	c = str(bin(a ^ b)[2:])
	if c.count('1') <= k:
		friends += 1
print(friends)


(n, m, k) = map(int, input().split())
a = list([])
for i in range(m + 1):
	l = int(input())
	a.append(l)
ans = 0
for i in range(m):
	bi = a[i] ^ a[m]
	s = bin(bi)
	r = 0
	j = 2
	while r <= k and j < len(s):
		if s[j] == '1':
			r += 1
		j += 1
	if r <= k:
		ans += 1
print(ans)


(n, m, k) = [int(i) for i in input().split()]
lst = []
for i in range(0, m + 1):
	a = int(input())
	lst.append(a)
m = lst[-1]
lst.pop()
nd = 0
for i in lst:
	if bin(m ^ i)[2:].count('1') <= k:
		nd += 1
print(nd)


(n, m, k) = map(int, input().strip().split(' '))
li = []
for _ in range(m):
	li.append(int(input()))
fedora = int(input())
count = 0
for i in li:
	x = i ^ fedora
	j = 0
	while x:
		x = x & x - 1
		j += 1
	if j <= k:
		count += 1
print(count)


(n, m, k) = [int(n) for n in input().split()]
soldier = []
for i in range(m):
	a = int(input())
	soldier.append(a)
Fedor = int(input())
sum = 0
for i in soldier:
	tmp = Fedor ^ i
	s = bin(tmp)
	check = s.count('1')
	if check <= k:
		sum += 1
print(sum)


def areFriends(a, b, k):
	ans = str(bin(a ^ b))
	return ans.count('1') <= k
(n, m, k) = map(int, input().strip().split())
x = [int(input().strip()) for i in range(m + 1)]
fedor = x[m]
c = 0
for i in range(m):
	if areFriends(x[i], fedor, k):
		c += 1
print(c)


import sys
(n, m, k) = map(int, sys.stdin.readline().split())
alist = []
for i in range(m):
	alist.append(int(input()))
fedor = int(input())
ans = 0
for i in range(m):
	a = fedor ^ alist[i]
	s = sum([int(j) for j in bin(a)[2:]])
	if s <= k:
		ans += 1
print(ans)


import math, os, sys
import string, re
from itertools import *
from collections import Counter
from operator import mul

def inputint():
	return int(input())

def inputarray(func=int):
	return map(func, input().split())

def inputarray2(n, func=int):
	for _ in range(n):
		yield func(input())
(n, m, k) = inputarray()
A = list(inputarray2(m + 1))
res = [None] * (m + 1)
for (i, v) in enumerate(A):
	res[i] = bin(v ^ A[-1]).count('1')
print(sum(map(lambda x: x <= k, res)) - 1)


(n, m, k) = [int(x) for x in input().split(' ')]
b = []
for x in range(m + 1):
	a = int(input())
	c = []
	while a >= 1:
		c.append(a % 2)
		a //= 2
	c += (n - len(c)) * [0]
	b.append(c)
c = b[-1]
ans = 0
for x in range(m):
	a = b[-1]
	f = list(zip(a, b[x]))
	check = list(filter(lambda x: x[0] != x[1], f))
	if len(check) <= k:
		ans += 1
print(ans)