#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, ll> P;
typedef tuple<int, ll, ll> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const ll inf = 1e18 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, k, s, t;
int a[55];

ll comb[55][55];

bool check(int v) {
    for (int i = 0; i < 18; i++) {
        if (((s>>i)&1) == 1 && ((t>>i)&1) == 1) {
            if (((v>>i)&1) == 0)
                return false;
        } else if (((s>>i)&1) == 0 && ((t>>i)&1) == 0) {
            if (((v>>i)&1) == 1)
                return false;
        }
    }
    return true;
}


ll solve() {
    comb[0][0] = 1;
    for (int i = 1; i <= 50; i++) {
        comb[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
        }
    }
    
    vector<int> amb;
    for (int i = 0; i < 18; i++) {
        if (((s>>i)&1) == 1 && ((t>>i)&1) == 0)
            return 0;
        if (((s>>i)&1) == 0 && ((t>>i)&1) == 1)
            amb.push_back(i);
    }

    vector<int> cand;
    for (int i = 0; i < n; i++) {
        if (check(a[i])) {
            cand.push_back(a[i]);
        }
    }

    ll res = 0;
    const int c = (int)cand.size();
    for (int i = 1; i <= min(c,k); i++) {
        res += comb[c][i];
    }

    const int sz = (int)amb.size();
    for (int i = 1; i < (1<<sz); i++) {
        vector<int> amb_pos;
        for (int j = 0; j < sz; j++) {
            if ((i>>j)&1) {
                amb_pos.push_back(amb[j]);
            }
        }
        const int popcnt = (int)amb_pos.size();
        map<int, int> m;
        for (int v : cand) {
            int val = 0;
            for (int j = 0; j < popcnt; j++) {
                val |= (((v>>amb_pos[j])&1)<<j);
            }
            m[val]++;
        }
        for (auto p : m) {
            for (int j = 1; j <= min(p.second, k); j++) {
                if (popcnt % 2 == 0) {
                    res += comb[p.second][j];
                } else {
                    res -= comb[p.second][j];
                }
            }
        }
    }
    return res;
}

void input() {
    cin >> n >> k >> s >> t;
    for (int i = 0; i < n; i++) cin >> a[i];
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3216