fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map { it.toLong() }
    val a = readLine()!!.split(' ').map { it.toLong() }

    val k1 = k + 1

    var res = 0L

    for (i in 0..39) {

        if (k1 and (1L shl i) > 0) {
            var x = 0L

            for (j in 0..39) {

                if (j < i) {
                    val c = a.filter { it and (1L shl j) == 0L }.count()
                    if (c > n / 2) {
                        x += 1L shl j
                    }
                    continue
                }

                if (j > i) {
                    x += k1 and (1L shl j)
                    continue
                }

            }

            res = Math.max(res, a.map { it xor x }.sum())
        }

    }

    println(res)
}
