PROGRAM ATCODER

implicit none
integer(8) :: n, k, i, j, sizemax_a, sizemax_k, x_ans
integer(8),allocatable :: a(:), count(:), x(:), ans(:), size(:)

read(*,*) n, k
allocate(a(n))
allocate(size(n))

read(*,*) (a(i), i=1,n)

if(k==0)then
	write(*,'(i0)') sum(a)
    stop
end if

do i = 1, n
	size(i) = log(real(a(i)))/log(2.d0) + 1
end do

sizemax_a = maxval(size)
sizemax_k = log(real(k))/log(2.d0) + 1
allocate(x(sizemax_k)) ! x(1)に2^0、x(2)に2^1、、、
allocate(ans(sizemax_k))
allocate(count(sizemax_k)) ! iビット目が1である数
count = 0

do i = 1, sizemax_k
	count(i) = 0
	do j = 1, n
		if(btest(a(j),i-1))then
    		count(i) = count(i) + 1
    	end if
    end do
end do

ans(1) = 0
if (mod(k,2) /= 0)then
	do i = 1, n
		ans(1) = ans(1) + xor(k-1,a(i))
    end do
end if


do i = 2, sizemax_k
	x(i) = 0
    do j= 1, i-1
    	if (count(j) > n-count(j)) then
        	x(j) = 1
		else
        	x(j) = 0
        end if
	end do
    ans(i) = 0
    x_ans = k
    if (btest(k,i-1)) then
    	x_ans = x_ans - 2**(i-2)
    end if
    do j = 1, i-1
    	x_ans = x_ans - 2*x(j)**(j-1)
    end do
    do j = 1, n
    	ans(i) = ans(i) + xor(x_ans,a(j))
	end do 
end do

write(*,'(i0)') maxval(ans)

END PROGRAM ATCODER