Problem: 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 xi. Consider binary representation of xi: if the j-th bit of number xi 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 xi (1 ≤ xi ≤ 2n - 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

Solution (in JAVA):

Solution:
import java.io.IOException;
import java.util.Scanner;

public class Solution {

	public static void main(String[] args) throws IOException {
		int n = Reader.nextInt();
		int m = Reader.nextInt();
		int k = Reader.nextInt();
		int[] x = Reader.nextInts(m + 1);
		int result = solve(n, m, k, x);
		System.out.println(result);
	}

	private static int solve(int n, int m, int k, int[] x) {
		int friendsCount = 0;
		for (int i = 0; i < m; i++) {
			int onesCount = countOnes(Integer.toBinaryString(x[m] ^ x[i]));
			if (onesCount <= k)
				friendsCount++;
		}
		return friendsCount;
	}

	private static int countOnes(String binaryString) {
		int count = 0;
		char[] chars = binaryString.toCharArray();
		for (char ch : chars) {
			if (ch == '1')
				count++;
		}
		return count;
	}
}

class Reader {

	private static Scanner in = new Scanner(System.in);

	private Reader() {

	}

	public static int nextInt() {
		return in.nextInt();
	}

	public static int[] nextInts(int k) {
		int[] arr = new int[k];
		for (int i = 0; i < k; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

}

class Algorithm {

	public static String convertToBinary(int x) {
		// method 1 >> Integer.toBinaryString(x);
		// method 2 >> new BigInteger(x + "").toString(2);
		// method 3
		StringBuilder str = new StringBuilder();
		while (x > 0) {
			str.append(x % 2);
			x = x / 2;
		}
		return str.toString();
	}

	public static int binarySearch(int[] arr, int start, int end, int x) {
		while (start <= end) {
			int mid = (start + end) / 2;
			if (x == arr[mid])
				return mid;
			else if (x > arr[mid])
				return binarySearch(arr, mid + 1, end, x);
			else
				return binarySearch(arr, start, mid - 1, x);
		}
		return -1;
	}

	public static int gcd(int a, int b) {
		if (b == 0)
			return a;
		return gcd(b, a % b);
	}

	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		for (int i = 2; i <= Math.sqrt(n); i++) {
			if (n % i == 0)
				return false;
		}
		return true;
	}

}

class Template implements Comparable<Template> {

	int key;
	int value;

	public Template(int key, int value) {
		this.key = key;
		this.value = value;
	}

	public int getKey() {
		return key;
	}

	public int getValue() {
		return value;
	}

	@Override
	public int compareTo(Template other) {
		return Integer.compare(key, other.key);
	}

	@Override
	public String toString() {
		return "Template [key=" + key + ", value=" + value + "]";
	}
}