#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using i128 = __int128_t;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int kthbit(int x, int k) {
    return ((x>>k)&1);
}

struct Combination {
    vector<vector<ll>> C;
    Combination(int N) {
        C.resize(N+1, vector<ll>(N+1));
        C[0][0] = 1;
        rep(i,N) {
            rep(j,i+1) {
                C[i+1][j] += C[i][j];
                C[i+1][j+1] += C[i][j];
            }
        }
    }

    ll get(int n, int k) {
        if (k < 0 || k > n) return 0;
        return C[n][k];
    }
};

int main() {
    int N,K,S,T; cin >> N >> K >> S >> T;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<int> B(18,-1),D;
    rep(i,18) {
        int s = kthbit(S,i);
        int t = kthbit(T,i);
        if (s==0 and t==0) B[i] = 0;
        else if (s==1 and t==1) B[i] = 1;
        else if (s==0 and t==1) D.emplace_back(i);
        else {
            cout << 0 << ln;
            return 0;
        } 
    }

    vector<int> C;
    rep(i,N) {
        bool ok = true;
        rep(k,18) {
            if (~B[k]) {
                int b = kthbit(A[i],k);
                if (b^B[k]) ok = false;
            }
        }
        if (ok) C.emplace_back(A[i]);
    }

    int M = C.size();
    int L = D.size(); 
    vector<vector<int>> cnt(M+1, vector<int>(1<<L));
    vector<int> arr(1<<18);
    rep(mask,1<<L) {
        int tmp = 0;
        rep(i,L) {
            if (mask&(1<<i)) tmp |= (1<<D[i]);
        }
        rep(i,M) {
            arr[tmp&C[i]]++;
        }
        rep(i,M) {
            if (arr[tmp&C[i]]==0) continue;
            cnt[arr[tmp&C[i]]][mask]++;
            arr[tmp&C[i]] = 0;
        }
    }

    ll ans = 0;
    Combination Com(50);
    for (int k = 1; k <= K; k++) {
        rep(i,M+1) {
            rep(mask,1<<L) {
                if (popcount(mask)&1) ans -= Com.get(i,k)*cnt[i][mask];
                else ans += Com.get(i,k)*cnt[i][mask];
            }
        }
    }
    cout << ans << ln;
}

Measured memory_bytes: 56768