//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 51;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

ll C[N][N];
ll R[N];

int K;

void init() {
    rep(i, 0, N) {
        C[i][0] = 1;
        rep(j, 1, i + 1) {
            C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
        }
    }
    rep(i, 0, N) {
        rep(j, 1, K + 1) {
            R[i] += C[i][j];
        }
    }
}

ll solve(int p, vector<int> a) {
    int n = sz(a);
    if (n == 0) {
        return 0;
    }
    if (p == -1) {
        /*cout << p << "\n";
        for (int i : a) {
            cout << i << " ";
        }
        cout << "\n";
        cout << R[n] << "\n";
        cout << "\n";*/
        return R[n];
    }
    ll tot = solve(p - 1, a);
    vector<int> a0, a1;
    rep(i, 0, n) {
        if ((a[i] >> p) & 1) {
            a1.push_back(a[i]);
        } else {
            a0.push_back(a[i]);
        }
    }
    tot -= solve(p - 1, a0);
    tot -= solve(p - 1, a1);
    /*cout << p << "\n";
    for (int i : a) {
        cout << i << " ";
    }
    cout << "\n";
    cout << tot << "\n";
    cout << "\n";*/
    return tot;
}

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, S, T;
    cin >> n >> K >> S >> T;
    init();
    if (!((S & T) == S)) {
        cout << 0 << "\n";
        return 0;
    }
    vector<int> a;
    int ccc = 0;
    rep(i, 0, n) {
        int x;
        cin >> x;
        int cur_b = 0, cur_x = 0;
        bool bad = false;
        rep(b, 0, 18) {
            int x_b = (x >> b) & 1, S_b = (S >> b) & 1, T_b = (T >> b) & 1;
            if ((x_b == 0 && S_b == 1) || (x_b == 1 && T_b == 0)) {
                bad = true;
            }
            if (S_b == 0 && T_b == 1) {
                cur_x += x_b * (1 << cur_b);
                cur_b++;
            }
        }
        ccc = cur_b;
        if (!bad) {
            a.push_back(cur_x);
        }
    }
    cout << solve(ccc - 1, a) << "\n";
    return 0;
}



Measured memory_bytes: 3708