PROGRAM ATCODER

implicit none
integer(16) :: n, k, sizek, sizea, i, j
integer(16),allocatable :: a(:), count(:), size(:), ans(:), x(:)

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

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

if (k == 0) then
	sizek = 1
else
	sizek = log(real(k))/log(2.d0) + 1
end if

allocate(ans(sizek+1))
allocate(x(sizek))
x = k
ans = 0

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

sizea = maxval(size)

allocate(count(sizea)) ! count(1)=1ビット目が1の数はいくつあるか
count = 0

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

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

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

do i = 1, n
	ans(sizek+1) = ans(sizek+1) + xor(k,a(i))
end do

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

END PROGRAM ATCODER
