object Main extends App {
  val in = scala.io.Source.stdin.getLines.toSeq
  val ls = in.map(_.split(' ').map(_.toLong).toArray)
  val N = ls(0).head
  val K = ls(0).tail.head
  val s = ls(1)
  
  val count = (0 to 63).map(_ => 0).toArray
  private def func(l:Long){
    var ll = l
    (0 to 63).map{i =>
      if(ll % 2 == 1) count(i) += 1
      ll = ll / 2
    }
  }
  s.foreach(func)
  val bools = count.map(_ <= N/2)
  //println(count.toSeq)
  //println(bools.toSeq)
  
  var syn = 0L
  (0 to 63).map{i =>
    syn = syn*2
    if(bools(63-i)) syn += 1
  }
  //println(syn)
  val X = syn & K
  //println(X)
  
  val ret = s.foldLeft(0L){(a,e) => a + (e ^ X)}
  println(ret)
}
