//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include <ctime>
#include<list>
#include <numeric>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include <array>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(int i = 0; i < n; i++)
#define FORAB(i, a, b) for(int i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))
#define AIN(A, B, C) assert(IN(A, B, C))

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

typedef long long int LL;
//typedef __int128 LLL;
typedef long long LLL;

typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PLL> VPL;
typedef vector<PII> VP;
typedef vector<double> VD;
typedef vector<vector<int>> VVI;
typedef vector<string> VS;
typedef long double ld;

#define MAXN 1000006
//#define MAXN 1006

const LL MOD = 1000000007;
//const LL MOD = 998244353;
const LL INF = 2000000000000000001LL; //2e18 + 1

struct SubsetCounting {
	// Given frequency array(frequencies) and a mask(mask),
	// Returns sum of frequencies[s] where s is a submask of mask.
	// Complexity: O(number of submasks of the mask).
	template<class T>
	static T SubsetSum(vector<T>& frequencies, int mask) {
		assert(SZ(frequencies) > 0 && mask < SZ(frequencies));
		T sum = frequencies[0];
		for (int submask = mask; submask; submask = (submask - 1) & mask) {
			sum = sum + frequencies[submask];
		}
		return sum;
	}

	// Given frequency array(frequencies),
	// Returns a vector, ret[i] = sum of array[s] where s is a submask of i.
	// Complexity: O(nlogn) where n = |frequencies|.
	template<class T>
	static vector<T> SubsetSums(vector<T>& frequencies) {
		vector<T> ret = frequencies;
		int bit = 0;
		while ((1 << bit) < SZ(frequencies)) bit++;
		for (int i = 0; i < bit; i++) {
			for (int mask = 0; mask < SZ(frequencies); mask++) {
				if (mask & (1 << i)) {
					ret[mask] = ret[mask] + ret[mask ^ (1 << i)];
				}
			}
		}
		return ret;
	}

	// Returns frequency of a given mask where
	// subset_sums array is given, where subset_sums[i] is sum of frequency[s] where s is subset of i.
	// Complexity: O(number of submasks of the mask)
	template<class T>
	static T GetFrequency(vector<T>& subset_sums, int mask) {
		assert(SZ(subset_sums) > 0 && mask < SZ(subset_sums));
		T sum = 0;
		for (int submask = mask; ; submask = (submask - 1) & mask) {
			sum = sum + subset_sums[submask] * ((__builtin_popcount(mask ^ submask) & 1) ? -1 : 1);
			if (submask == 0) break;
		}
		return sum;
	}

	// Returns frequency array of a given subset_sums array
	// where subset_sums[i] is sum of frequencies[s] where s is subset of i.
	// Complexity: O(nlogn) where n = |subset_sums|.
	template<class T>
	static T GetFrequencies(vector<T>& subset_sums) {
		vector<T> ret = subset_sums;
		int bit = 0;
		while ((1 << bit) < SZ(subset_sums)) bit++;
		for (int i = bit - 1; i >= 0; i--) {
			for (int mask = SZ(subset_sums) - 1; mask >= 0; mask--) {
				if (mask & (1 << i)) {
					ret[mask] = ret[mask] - ret[mask ^ (1 << i)];
				}
			}
		}
		return ret;
	}
};

int n, k, sand, tor;
vector<int> A;
vector<vector<LL>> ncr;

LL CalcNcr(int n, int r) {
	if (r > n) return 0;
	while (ncr.size() < n + 1) {
		int i = ncr.size();
		ncr.push_back(VL(i + 1, 0));
		for (int j = 0; j <= i; j++) {
			if (i == 0 && j == 0) {
				ncr[i][j] = 1;
			}
			else if (j == i || j == 0) ncr[i][j] = 1;
			else ncr[i][j] = ncr[i - 1][j - 1] + ncr[i - 1][j];
		}
	}
	return ncr[n][r];
}

LL Calc() {
	if ((tor & sand) != sand) {
		return 0;
	}

	{
		vector<int> B;
		for (int a : A) {
			if ((a & sand) == sand) {
				B.push_back(a);
			}
		}
		A.swap(B);
	}

	{
		vector<int> B;
		int tmp = ((1 << 18) - 1) ^ tor;
		for (int a : A) {
			if (!(a & tmp)) {
				B.push_back(a);
			}
		}
		A.swap(B);
	}

	// AND, OR, F, O = 1, 1, 1, 1 DONE
	// AND, OR, F, O = 0, 0, 0, 0 DONE
	// AND, OR = 1, 0 DONE
	// AND, OR, F, O = 0, 1, 1 => WANT 0
	// AND, OR, F, O = 0, 1, 0 => WANT 1
	VL cntK(51, 0);
	for (int i = 0; i <= 50; i++) {
		for (int j = 0; j <= i && j < k; j++) {
			cntK[i] += CalcNcr(i, j);
		}
	}
	LL ans = 0;
	for (int i = 0; i < SZ(A); i++) {
		int want_0 = (tor ^ sand) & A[i];
		int want_1 = (tor ^ sand) & (((1 << 18) - 1) ^ A[i]);
		VL subset_sums(1 << 18, 0);
		for (int j = i + 1; j < SZ(A); j++) {
			if (i == j) continue;
			int mask = (want_1 & A[j]) + (want_0 & (((1 << 18) - 1) ^ A[j]));
			subset_sums[mask]++;
		}
		subset_sums = SubsetCounting::SubsetSums(subset_sums);
		for (int j = 0; j < (1 << 18); j++) {
			subset_sums[j] = cntK[subset_sums[j]];
		}
		ans += SubsetCounting::GetFrequency(subset_sums, want_0 | want_1);
	}
	return ans;
}
void solve(int ks) {
	scanf("%d %d %d %d", &n, &k, &sand, &tor);
	A.resize(n);
	FORN(i, n) scanf("%d", &A[i]);
	LL ans = Calc();
	printf("%lld\n", ans);
}

void gen() {
}

int main()
{
	double start_time = clock();
#ifdef LOCAL
	freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	// freopen("C:\\Home\\ContestCodes\\sample.in", "r", stdin);
	//	freopen("out.out", "w", stdout);
#endif

	gen();

	if (0) {
		int T;
		scanf("%d", &T);
		//AIN(T, 1, 5000);
		for (int ks = 1; ks <= T; ks++) {
			solve(ks);
			if (ks % 1 == 0) fprintf(stderr, "%d done\n", ks);
		}
	}
	else {
		solve(0);
	}

	double end_time = clock();
	fprintf(stderr, "Time = %lf\n", (end_time - start_time) / CLOCKS_PER_SEC);

	return 0;
}


Measured memory_bytes: 7576