#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) ;
#endif


typedef long long ll;
typedef long double ld;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)((x).size())
#define pb push_back
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
#define X first
#define Y second
//#define debug(x) cerr << #x << " : " << (x) << " "
const double PI = 3.14159265358979323846;
const double eps = (1e-9);
//int isGreater(long double x, long double y)
//{
//    if (abs(x - y) < eps)
//        return 0;
//    if (x > y)
//        return 1;
//    return -1;
//}

const int MAX_N = 53, L = 18;
bool isSubmask(int submsk, int msk)
{
    return (msk&submsk) == submsk;
}
ll C[MAX_N][MAX_N];
void genComb()
{
    C[0][0] = 1;
    for (int r = 1; r < MAX_N; ++r)
    {
        C[r][0] = 1;
        C[r][r] = 1;
        for (int j = 1; j < r; ++j)
        {
            C[r][j] = C[r-1][j] + C[r-1][j-1];
        }
    }

    for (int r = 0; r < MAX_N; ++r)
    {
        C[r][0] = 0;
        for (int j = 1; j < MAX_N; ++j)
            C[r][j] += C[r][j - 1];
    }
}

ll F[(1<<L) + 1];

int countZeros(int msk)
{
    return 31 - __builtin_popcount(msk);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    genComb();
    int n, k, A, O;
    cin >> n >> k >> A >> O;
    vector<int> a(n);
    rep(i,0,n)
        cin >> a[i];
    if (!isSubmask(A, O))
    {
        cout << 0 << '\n';
        return 0;
    }
    vector<int> v;
    rep(i,0,n)
    {
        if (isSubmask(a[i], O) && isSubmask(A, a[i]))
            v.push_back(a[i]);
    }

    n = sz(v);
    int M = A^O;
    if (!M)
    {
        cout << C[n][k] << '\n';
        return 0;
    }


    ll ans = 0;
    for (int first = 0; first < n; ++first)
    {
        vector<int> vTemp(all(v));
        clr(F, 0);
        for (int i = first + 1; i < n; ++i)
        {
            vTemp[i] = v[i] ^ v[first];
            F[vTemp[i]]++;
        }
        for (int i = 0; i < L; ++i)
            for (int msk = 0; msk < (1<<L); ++msk)
                if (msk & (1<<i))
                    F[msk] += F[msk^(1<<i)];

        ans += C[n - first - 1][k - 1];
        for (int msk = 0; msk < (1<<L); ++msk)
        {
            if (!isSubmask(msk, M) || msk == M)
                continue;
            ll temp = C[F[msk]][k - 1];
            int z = countZeros(msk) - countZeros(M);
            if (z&1)
                ans -= temp;
            else
                ans += temp;
        }
    }


    cout << ans << '\n';
}

Measured memory_bytes: 5688