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 = {
    val calc0 = calc(list, 0)
    if(k == 0){
      calc0
    }
    else if(k == 1){
      Math.max(calc0, calc(list,1))
    }
    else {
      val dig: Int = Math.floor(Math.log(k) / Math.log(2)).toInt
      val ansX = recursive(dig, list, calc0)
      calc(list, ansX)
    }
  }

  def calc(list: List[Long], x: Long):Long = {
    list.map(a => a^x).sum
  }

  def recursive(d:Int, list:List[Long], calc0:Long) : Long = {
    if(d == 0){
      if(calc0 > calc(list,1)) 0 else 1
    }
    else{
      val d2 = 1 << d
      (if(calc0 > calc(list, d2)) 0 else d2) + recursive(d-1, list, calc0)
    }
  }
}
