PROGRAM ATCODER

implicit none
integer :: n, k, i, j
integer,allocatable :: a(:), f(:)

read(*,*) n,k
allocate(a(n))
allocate(f(k))
read(*,*) (a(i), i = 1,n)

do i = 1, k
	f(i) = 0
	do j = 1, n
		f(i) = f(i) + xor(i,a(j))
    end do
end do

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

END PROGRAM ATCODER
