object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt()
    val k = sc.nextLong()
    val list = List.fill(n)(sc.nextLong)
    println(func(n,k,list))
  }

  def func(n:Int, k:Long, list:List[Long]) : Long = {
    if(k == 0){
      list.map(a => a^0).sum
    }
    else {
      val dig: Int = Math.floor(Math.log(k) / Math.log(2)).toInt
      val ansX = (for (d <- 0 to dig) yield {
        val d2 = 1 << d
        //        println(list.map(x => x & d2))
        val count = list.map(x => x & d2).count(_ > 0)
        if(count*2 > n) 0 else d2
      }).sum
      list.map(a => a^ansX).sum
    }
  }
}