object Main extends App {
  val in = new java.util.Scanner(System.in)
  val n = in.nextInt
  val k = in.nextLong
  val msb =  63 - java.lang.Long.numberOfLeadingZeros(k)
  val as = Array.fill(n)(in.nextLong)
  val bit: Int => Int = shift => if (as.count(i => (i & (1L << shift)) != 0) > n / 2) 0 else 1
  val op = (msb to 0 by -1).foldLeft(0L){(z, shift) => (z << 1) + bit(shift)}
  println(as.foldLeft(0L)((z, i) => z + (i ^ op)))
}