program abc117d
  integer(8) n, k, i, v
  integer(8), allocatable :: a(:)
  read *, n, k
  allocate(a(n))
  read *, a
  v = 0
  do i = 38, 0, -1
     if (count(btest(a, i)) * 2 <= n .and. v + 2**i <= k) then
        v = v + 2**i
     end if
  end do
  print *, sum(ieor(a, v))
end program abc117d
