import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val K = sc.nextLong()
    val A = LongArray(N){0L}
    val bit = IntArray(40){0}// 10^12 < 2^40
    for (i in 0 until N) {
        A[i] = sc.nextLong()
        val a = java.lang.Long.toBinaryString(A[i])
        for (i in 0 until a.length)
            if(a[i] == '1') bit[40-a.length+i]++ 
    }
    
    //bit.forEach{print("$it ")}
    var isK = true
    val Kbi = "%40s".format(java.lang.Long.toBinaryString(K).toString()).replace(" ","0")
    var x = ""
    for (i in 0 until 40) {
        if(bit[i] > N/2 || (isK && Kbi[i] == '0')) x += "0"
        else x += "1"
        if (!isK || Kbi[i] != x[i]) isK = false
    }
    val X = java.lang.Long.parseLong(x,2)
    var ans = 0L
    A.forEach{ans += X xor it}
    println(ans)
}