import io.{StdIn => in}

object Main extends App {
  val Array(n, k) = in.readLine.split(" ").map(_.toLong)
  val a = in.readLine.split(" ").map(_.toLong)
  // println(a.max ^ k)
  def f(num:Long):Long = {
    var res = 0L
    def rec(acc:Long, cnt:Int):Long = {
      if(acc > num) res
      else {
        res = acc
        rec(acc<<1, cnt + 1)
      }
    }
    rec(1,0)
  }

  val mask = f(k)
  val res1 = a.map(_^mask).sum
  val res2 = a.map(_^(mask>>1)).sum
  val ans = math.max(res1,res2)
  println(ans)
}
