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 A = Array.fill(N)(sc.nextLong())

    // 各ビット桁毎に足し算は独立できる。
    // 各ビット桁毎に, 0が多ければ1を対応させ, 1が多ければ0を対応させる.
    val BIT_COUNT_1, BIT_COUNT_0 = new Array[Int](40)

    A.foreach { A =>
      val AB = A.toBinaryString.reverse.padTo(40, '0')
      var i = 0
      while (i < AB.length) {
        AB(i) match {
          case '1' => BIT_COUNT_1(i) += 1
          case '0' => BIT_COUNT_0(i) += 1
        }
        i += 1
      }
    }
    
    val X = java.lang.Long.parseLong(BIT_COUNT_0.zip(BIT_COUNT_1). map { bit =>
      if (bit._1 > bit._2) '1'
      else '0'
    }. reverse. mkString, 2) & K

    val r = A.foldLeft(0L)((b, n) => b + (n ^ X))

    println(r)
  }

}