#include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#include<memory>

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;
using ll = long long int;

using Graph=vector<vector<int>>;
	
#define WHATS(var)//cout<<__LINE__<<' '<<#var<<"="<<var<<endl;
	
template<class S, class T> ostream& operator <<(ostream &os, const pair<S, T> v){
	os << "( " << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<T> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<vector<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const vector<set<T>> &v){
	for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> ostream& operator <<(ostream &os, const set<T> &v){
	int i=0;
	for(auto it:v){
		if(i > 0){os << ' ';}
		os << it;
		i++;
	} 
	return os;
}

#include<random>
const int mod=1e9+7;

vector<vector<ll>>memo(51,vector<ll>(51));
vector<vector<ll>>sums(51,vector<ll>(51));

void init(){
    for(int i=1;i<=50;++i){
        for(int j=1;j<=i;++j){
            ll answer=1;
            for(int k=0;k<j;++k){
                answer*=i-k;
                answer/=k+1;
            }
            memo[i][j]=answer;
        }
    }
    for(int i=0;i<=50;++i){
        for(int j=1;j<=50;++j){
            if(j!=1)sums[i][j]+=sums[i][j-1];
            sums[i][j]+=memo[i][j];
        }
    }
    //WHATS(sums)
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie();
    init();
    int N,K,S,T;cin>>N>>K>>S>>T;

    vector<int> t_on_places;
    for(int i=0;i<18;++i){
        if((T&(1<<i))&&(!(S&(1<<i))))t_on_places.push_back(i);
    }
    WHATS(t_on_places)
    vector<int>as;
    int aN=N;
    for(int i=0;i<N;++i){
        int a;cin>>a;
        if(((a&S)!=S)||((a&T)!=a)){
            aN--;
        }else{
            as.push_back(a);
        }
    }
    N=aN;
    WHATS(as)
    N=int(as.size());

    ll answer=0;
    if((S&T)!=S){

    }else{
        vector<vector<ll>>vs(t_on_places.size(),vector<ll>(2));

        for(int i=0;i<N;++i){
            auto kk=as[i]^S;

            for(int j=0;j<t_on_places.size();++j){
                int xx=t_on_places[j];
                if((kk>>xx)&1){
                    vs[j][0]^=1ll<<i;
                }else{
                    vs[j][1]^=1ll<<i;
                }
            }
        }

        for(int id=0;id<1<<(t_on_places.size());++id){
            bool flag=__builtin_popcount(id)%2;

            vector<ll>nums(1,(1ll<<N)-1);
            for(int j=0;j<t_on_places.size();++j){
                vector<ll>nnums;
                if(id&(1<<j)){
                    for(auto nu:nums){
                        ll l_use=nu&vs[j][0];
                        ll r_use=nu&vs[j][1];
                        assert((l_use^r_use)==nu);
                        assert(!(l_use&r_use));
                        //WHATS(l_use)
                        //WHATS(r_use)
                        if(l_use){
                            nnums.push_back(l_use);

                        }
                        if(r_use){
                            nnums.push_back(r_use);
                        }
                    }
                nums=nnums;

                }

               
            }
            WHATS(id)
            WHATS(nums)
             ll plus=0;
             for(auto nu:nums){
                 plus+=sums[__builtin_popcountll(nu)][K];
             }
             if(flag)answer+=plus;
             else answer-=plus;
             WHATS(plus)
             WHATS(answer)
                
        }
        WHATS(vs)
    }
    answer=abs(answer);
    cout<<answer<<endl;
    
	return 0;
}

Measured memory_bytes: 3712