program o_rand
  implicit none
  integer :: n, k, s, t, a(50) = 0, b(50) = 0, m = 0, i, j, l, p
  integer :: y(50,50) = 0
  integer(8) :: ans = 0, comb(0:50,0:50) = 0
  logical :: x(50) = .true.
  read(*,*) n, k, s, t
  if (and(s,t) /= s) then
    write(*,'(i0)') 0
    stop
  end if
  comb(0,0) = 1
  do i = 1, 50
    comb(i,0) = 1
    comb(i,i) = 1
    do j = 1, i-1
      comb(i,j) = comb(i-1,j-1)+comb(i-1,j)
    end do
  end do
  read(*,*) a(1:n)
  do i = 0, 18
    if (.not. btest(s,i)) cycle
    do j = 1, n
      if (.not. btest(a(j),i)) x(j) = .false.
    end do
  end do
  do i = 0, 18
    if (btest(t,i)) cycle
    do j = 1, n
      if (btest(a(j),i)) x(j) = .false.
    end do
  end do
  do i = 1, n
    if (x(i)) then
      m = m+1
      b(m) = a(i)
    end if
  end do
  do i = 0, 18
    if (btest(s,i) .or. (.not. btest(t,i))) cycle
    do j = 1, m
      if (.not. btest(b(j),i)) cycle
      do l = j+1, m
        if (btest(b(l),i)) y(j,l) = 1
      end do
    end do
  end do
  ans = sum(comb(m,1:k))
  do i = 1, m
    p = sum(y(i,i:m))
    ans = ans-sum(comb(p,0:k-1))
    if (t == s .and. b(i) == s) ans = ans+1
  end do
  write(*,'(i0)') ans
end program o_rand