/*
    author:  Maksim1744
    created: 13.06.2020 16:29:46
*/

#include <bits/stdc++.h>

using namespace std;

#define ll   long long
#define ld   long double

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T>& v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T>& v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T>& v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>& v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>& p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define TAG_LENGTH       25
#define LR_LEFT          left
#define LR_RIGHT         right
#define LR_VALUE         value
#define LR_SECOND_VALUE  mn
#include "C:/C++ libs/print.cpp"
#else
#define showl            42;
#define shows            42;
#define show(...)        42;
#define showm(...)       42;
#define showt(...)       42;
#define printTree(...)   42;
#define printGraph(...)  42;
#define printLRTree(...) 42;
#define printMatrix(...) 42;
#define printWGraph(...) 42;
#define debug     if (false)
#endif

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    vector<int> need0;
    vector<int> need1;
    vector<int> sth;
    vector<vector<ll>> C(55, vector<ll>(55, 0));
    vector<vector<ll>> Ck(55, vector<ll>(55, 0));
    for (int i = 0; i < C.size(); ++i) {
        C[0][i] = 0;
        C[i][0] = 1;
        Ck[0][i] = 1;
        Ck[i][0] = 1;
    }
    for (int i = 1; i < C.size(); ++i) {
        for (int j = 1; j < C.size(); ++j) {
            C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
            Ck[i][j] = Ck[i][j - 1] + C[i][j];
        }
    }
    int n, k, s, t;
    cin >> n >> k >> s >> t;
    vector<int> a(n);
    cin >> a;
    for (int i = 0; i < 18; ++i) {
        int band = ((s >> i) & 1);
        int bor = ((t >> i) & 1);
        if (band == 1 && bor == 0) {
            cout << 0 << '\n';
            return 0;
        }
        if (bor == 0)
            need0.pb(i);
        else if (band == 1)
            need1.pb(i);
        else
            sth.pb(i);
    }
    vector<int> b;
    for (int i = 0; i < n; ++i) {
        int x = a[i];
        bool ok = true;
        for (auto j : need0) {
            if (((x >> j) & 1) != 0) ok = false;
        }
        for (auto j : need1) {
            if (((x >> j) & 1) != 1) ok = false;
        }
        if (ok) {
            int y = 0;
            for (int j = 0; j < sth.size(); ++j) {
                y += ((x >> sth[j]) & 1) << j;
            }
            b.pb(y);
        }
    }
    a = b;
    ll ans = Ck[a.size()][k] - 1;
    if (sth.empty()) {
        cout << ans << endl;
        return 0;
    }
    // for (int s = 1; s <= k; ++s)
    //     ans += C[a.size()][s];
    // show(ans);
    // show(a);
    // show(sth.size());
    for (int i = 1; i < (1 << sth.size()); ++i) {
        ll sign;
        if (__builtin_popcount(i) % 2 == 1)
            sign = -1;
        else
            sign = 1;
        map<int, int> mm;
        for (auto x : a) {
            mm[x & i]++;
        }
        ll cnt = 0;
        for (auto [u, v] : mm) {
            cnt += Ck[v][k] - 1;
        }
        // show(i, mm, cnt);
        ans += cnt * sign;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3664