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

#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <unordered_map>
#include <stack>
#include <list>
#include <math.h>
#include <bitset>
#include <iterator>
#include <map>
#include <iomanip>
#include <functional>
#include <string>
#include <algorithm>
#include <queue>
#include <random>
#include <numeric>
#include <set>
#include <cassert>
#include <cmath>
#include <cinttypes>

using namespace std;

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { for (auto i = begin(v); i != end(v); i++) os << *i << (i == end(v) - 1 ? "" : " "); return os; }
template<class T> istream& operator>>(istream& is, vector<T>& v) { for (auto i = begin(v); i != end(v); i++) is >> *i; return is; }
struct fast_io {
	fast_io& operator>> (int& target) { scanf("%" PRId32, &target);  return *this; }
	fast_io& operator>> (unsigned int& target) { scanf("%" PRIu32, &target);  return *this; }
	fast_io& operator>> (long long& target) { scanf("%" PRId64, &target);  return *this; }
	fast_io& operator>> (unsigned long long& target) { scanf("%" PRIu64, &target);  return *this; }
	template<typename T> fast_io& operator>> (vector<T>& target) { for (auto& value : target) { *this >> value; } return *this; }
	fast_io& operator<< (const int value) { printf("%" PRId32, value); return *this; }
	fast_io& operator<< (const unsigned int value) { printf("%" PRIu32, value); return *this; }
	fast_io& operator<< (const long long value) { printf("%" PRId64, value); return *this; }
	fast_io& operator<< (const unsigned long long value) { printf("%" PRIu64, value); return *this; }
	fast_io& operator<< (const string& value) { printf("%s", value.c_str()); return *this; }
	template<typename T> fast_io& operator<< (const vector<T>& target) { for (auto& value : target) { *this << value << " "; } return *this; }
}; fast_io fio;

template<class ForwardIt, class UnaryPredicate>
ForwardIt first_true(ForwardIt first, ForwardIt last, UnaryPredicate predicate) {
	ForwardIt it;
	typename std::iterator_traits<ForwardIt>::difference_type count, step; count = std::distance(first, last);
	while (count > 0) {
		it = first;	step = count / 2;
		std::advance(it, step);
		if (!predicate(*it)) { first = ++it; count -= step + 1; }
		else count = step;
	}
	return first;
}

#define MOD 1000000007
#define pii pair<int,int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define sort_all(x) sort(all(x))
#define make_unique(x) (x).erase(unique(all(x)), (x).end())

long long binomialCoefficients(int n, int k) {
	vector<long long> C(70, 0);
	C[0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = min(i, k); j > 0; j--)
			C[j] = C[j] + C[j - 1];
	}
	return C[k];
}

long long calc_ways(vector<int>& nums, vector<long long>& cnts, int mask)
{
	map<int, int> mm;
	for (int x : nums)
	{
		mm[x & mask]++;
	}
	long long ret = 0;
	for (auto& x : mm)
	{
		ret += cnts[x.second];
	}
	return ret;
}

int main() {

#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int n, k, s, t;
	fio >> n >> k >> s >> t;

	vector<int> nums(n);
	fio >> nums;

	vector<bool> ok(n, true);
	vector<int> bits;
	for (int i = 0; i < 18; i++)
	{
		bool sb = ((1 << i) & s) > 0;
		bool tb = ((1 << i) & t) > 0;
		if (sb && !tb)
		{
			fio << 0;
			return 0;
		}
		if (sb == tb)
		{
			for (int j = 0; j < n; j++)
			{
				if ((nums[j] & (1 << i)) != ((1 << i) & s))
					ok[j] = false;
			}
		}
		else
		{
			bits.push_back(i);
		}
	}

	vector<int> nums2;
	for (int i = 0; i < n; i++)
	{
		if (!ok[i]) continue;
		int pos = 0, ans =0;
		for (int j : bits)
		{
			if ((1 << j) & nums[i])
				ans |= (1 << pos);
			pos++;
		}
		nums2.push_back(ans);
	}

	if (bits.size() == 0)
	{
		int x = 1 << nums2.size();
		fio << x - 1;
		return 0;
	}

	vector<long long> cnts;
	cnts.push_back(0);
	for (int i = 1; i <= n; i++)
	{
		long long ans = 0;
		for (int j = 1; j <= min(i, k); j++)
		{
			ans += binomialCoefficients(i, j);
		}
		cnts.push_back(ans);
	}

	long long resp = 0;
	int mx = 1 << bits.size();
	for (int mask = 0; mask < mx; mask++)
	{
		long long sign = (__builtin_popcount(mask) % 2 == 0) ? 1 : -1;
		resp += sign * calc_ways(nums2, cnts, mask);
	}
	fio << resp;

	return 0;
}

Measured memory_bytes: 3820