program o_rand_
  implicit none
  integer :: n, k, s, t, a(50) = 0, b(50) = 0, m = 0, f(0:262143) = 0, i, j, p
  integer(8) :: c(0:50, 0:50) = 0, g(0:50) = 0, x = 0, y
  read(*,*) n, k, s, t
  read(*,*) a(1:n)
  do i = 1, n
    if (and(a(i), s) /= s .or. or(a(i), t) /= t) cycle
    m = m + 1
    b(m) = xor(a(i), s)
  end do
  c(0, 0) = 1
  do i = 1, m
    c(0, i) = 1
    do j = 1, min(i, k)
      c(j, i) = c(j, i - 1) + c(j - 1, i - 1)
    end do
    g(i) = sum(c(1:k, i))
  end do
  s = xor(s, t)
  i = s
  do
    do j = 1, m
      p = and(b(j), i)
      f(p) = f(p) + 1
    end do
    y = 0
    do j = 1, m
      p = and(b(j), i)
      y = y + g(f(p))
      f(p) = 0
    end do
    x = x + merge(-y, y, btest(popcnt(i), 0))
    if (i == 0) exit
    i = and(i - 1, s)
  end do
  write(*,'(i0)') x
end program o_rand_