program xxor
  implicit none
  integer(8)              :: n, k, i, m, l
  integer(8), allocatable :: a(:)
  read(*,*) n, k
  allocate(a(n))
  read(*,*) a(:)
  m = 0
  do i = 0, k
     l = f(a,i)
     if (m .lt. l) m = l
  end do
  write(*,'(i0)') m
  deallocate(a)
  stop
contains
  function f(a,x) result(y)
    implicit none
    integer(8) :: x, a(:), n, i, y
    n = size(a)
    y = 0
    do i = 1, n
       y = y + xor(x,a(i))
    end do
    return
  end function f
end program xxor