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)
  var c = 0
  def f(num:Long):Long = {
    var res = 0L
    def rec(acc:Long, cnt:Int):Long = {
      if(acc > num) res
      else {
        res = acc
        c = cnt
        rec(acc<<1, cnt + 1)
      }
    }
    rec(1,0)
  }

  val mask = f(k)
  val ans = (
      for(i <- 0 to c) yield {
      a.map(_^(mask>>i)).sum
    }
  ).max
  println(ans)
}