import java.util.Scanner

object Main {
  def main(args:Array[String]) = {
    val sc = new Scanner(System.in)
    val N,K = sc.nextInt()
    val listA = List.fill(N)(sc.nextInt())

    val r = 0.until(K).toList.map{ X =>
      listA.map(a => X ^ a).sum
    }.sortWith((a, b) => a > b).head
    println(r)
  }
}