// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#define dibs reserve
#define OVER9000 1234567890
#define tisic 47
#define soclose 1e-8
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
using uint = unsigned int;
using cat = long long;
using dbl = long double;
constexpr dbl pi = 3.14159265358979323846;
using namespace std;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(10);
	int N, K, S, T;
	cin >> N >> K >> S >> T;
	if((S&T) != S) {
		cout << "0\n";
		return 0;
	}
	int B = __builtin_popcount(S^T);
	vector<int> A;
	for(int i = 0, a; i < N; i++) {
		// a = rand()%(1<<18);
		cin >> a;
		if((a&S) != S || (a|T) != T) continue;
		int b = 0;
		for(int j = 17; j >= 0; j--) if(((S^T)>>j)&1)
			b = 2*b + ((a>>j)&1);
		A.push_back(b);
	}
	N = A.size();
	K = min(N, K);
	vector<int> pw3(B+1, 1);
	for(int i = 1; i <= B; i++) pw3[i] = pw3[i-1] * 3;
	cat masks[100][2];
	for(int i = 0; i < B; i++) {
		cat m0 = 0, m1 = 0;
		for(int j = 0; j < N; j++) {
			if((A[j]>>i)&1) m0 |= 1LL<<j;
			else m1 |= 1LL<<j;
		}
		masks[i][0] = m1, masks[i][1] = m0;
	}
	vector< vector<cat> > C(N+1, vector<cat>(N+1, 0));
	for(int i = 0; i <= N; i++) {
		C[i][0] = 1;
		for(int j = 1; j <= i; j++) C[i][j] = C[i-1][j] + C[i-1][j-1];
	}
	vector<cat> cnt_maxK(N+1, 0);
	for(int i = 0; i <= N; i++) for(int j = 1; j <= K; j++) cnt_maxK[i] += C[i][j];
	int Br = (B >= 17) ? 16 : B;
	vector<cat> masks_opt(pw3[Br]);
	vector<char> bits_opt(pw3[Br]);
	masks_opt[0] = (1LL<<N)-1;
	bits_opt[0] = 0;
	for(int k = 0; k < Br; k++) for(int i = 0; i < pw3[k]; i++) {
		masks_opt[i+pw3[k]] = masks_opt[i] & masks[k][0];
		masks_opt[i+2*pw3[k]] = masks_opt[i] & masks[k][1];
		bits_opt[i+pw3[k]] = bits_opt[i] + 1;
		bits_opt[i+2*pw3[k]] = bits_opt[i] + 1;
	}
	cat ans = 0;
	if(B == 18) {
		for(int i = 0; i < pw3[Br]; i++) {
			cat x = cnt_maxK[__builtin_popcountll(masks_opt[i])];
			x -= cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][0])];
			x -= cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][1])];
			x -= cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[17][0])];
			x -= cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[17][1])];
			x += cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][0]&masks[17][0])];
			x += cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][1]&masks[17][1])];
			x += cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][1]&masks[17][0])];
			x += cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][0]&masks[17][1])];
			ans += (1-(bits_opt[i]&1)*2) * x;
		}
	}
	else if(B == 17) {
		for(int i = 0; i < pw3[Br]; i++) {
			cat x = cnt_maxK[__builtin_popcountll(masks_opt[i])];
			x -= cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][0])];
			x -= cnt_maxK[__builtin_popcountll(masks_opt[i]&masks[16][1])];
			ans += (1-(bits_opt[i]&1)*2) * x;
		}
	}
	else {
		for(int i = 0; i < pw3[Br]; i++)
			ans += (1-(bits_opt[i]&1)*2) * cnt_maxK[__builtin_popcountll(masks_opt[i])];
	}
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 381508