import std.conv, std.functional, std.range, std.stdio, std.string;
import std.algorithm, std.array, std.bigint, std.bitmanip, std.complex, std.container, std.math, std.mathspecial, std.numeric, std.regex, std.typecons;
import core.bitop;

class EOFException : Throwable { this() { super("EOF"); } }
string[] tokens;
string readToken() { for (; tokens.empty; ) { if (stdin.eof) { throw new EOFException; } tokens = readln.split; } auto token = tokens.front; tokens.popFront; return token; }
int readInt() { return readToken.to!int; }
long readLong() { return readToken.to!long; }
real readReal() { return readToken.to!real; }

bool chmin(T)(ref T t, in T f) { if (t > f) { t = f; return true; } else { return false; } }
bool chmax(T)(ref T t, in T f) { if (t < f) { t = f; return true; } else { return false; } }

int binarySearch(alias pred, T)(in T[] as) { int lo = -1, hi = cast(int)(as.length); for (; lo + 1 < hi; ) { const mid = (lo + hi) >> 1; (unaryFun!pred(as[mid]) ? hi : lo) = mid; } return hi; }
int lowerBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a >= val)); }
int upperBound(T)(in T[] as, T val) { return as.binarySearch!(a => (a > val)); }


enum E = 18;
enum LIM = 55;

void main() {
  auto bn = new long[][](LIM, LIM);
  foreach (n; 0 .. LIM) {
    bn[n][0] = bn[n][n] = 1;
    foreach (k; 1 .. n) {
      bn[n][k] = bn[n - 1][k - 1] + bn[n - 1][k];
    }
  }
  
  try {
    for (; ; ) {
      const N = readInt();
      const K = readInt();
      const S = readInt();
      const T = readInt();
      auto A = new int[N];
      foreach (i; 0 .. N) {
        A[i] = readInt();
      }
      
      bool ok = true;
      int req;
      auto can = new bool[N];
      can[] = true;
      foreach (e; 0 .. E) {
        if (!((S >> e) & 1)) {
          if (!((T >> e) & 1)) {
            // 0, 0
            foreach (i; 0 .. N) {
              can[i] = can[i] && !((A[i] >> e) & 1);
            }
          } else {
            // 0, 1
            req |= 1 << e;
          }
        } else {
          if (!((T >> e) & 1)) {
            // 1, 0
            ok = false;
          } else {
            // 1, 1
            foreach (i; 0 .. N) {
              can[i] = can[i] && ((A[i] >> e) & 1);
            }
          }
        }
      }
      debug {
        writeln("ok = ", ok);
        writeln("req = ", req);
        writeln("can = ", can);
      }
      
      long ans;
      if (ok) {
        int[] as;
        foreach (i; 0 .. N) {
          if (can[i]) {
            as ~= A[i];
          }
        }
        auto asLen = cast(int)(as.length);
        auto bs = new int[asLen];
        auto pats = new long[asLen + 1];
        foreach (n; 0 .. asLen + 1) {
          foreach (k; 1 .. K + 1) {
            pats[n] += bn[n][k];
          }
        }
        foreach (p; 0 .. 1 << E) {
          if (!(p & ~req)) {
            foreach (j; 0 .. asLen) {
              bs[j] = as[j] & p;
            }
            bs.sort;
            long sum;
            foreach (grp; bs.group) {
              sum += pats[grp[1]];
            }
            ans += (-1)^^(popcnt(p) & 1) * sum;
          }
        }
      }
      writeln(ans);
    }
  } catch (EOFException e) {
  }
}
