"use strict";
function Main(input) {
    let cin = new Inputer(input);
    let N = cin.getInt(), K = cin.getInt(), A = cin.getIntArray(N);
    const DIGIT = 40;
    const b2 = (v) => ('000000000000000000000000000000000000000' + v.toString(2)).substr(-DIGIT);
    let B = new Array(DIGIT).fill(0);
    for (let n = 0; n < N; n++) {
        let b = b2(A[n]);
        for (let m = 0; m < DIGIT; m++) if (b[m] == '1') B[m]++;
    }
    const kb = b2(K);
    let add = 0;
    for (let m = 0; m < DIGIT; m++) if (kb[m] == '1' && (N - B[m]) > B[m]) add += Math.pow(2, DIGIT - m - 1) * (N - 2 * B[m]);
    let ans = A.reduce((ac, v) => ac + v, add);
    console.log(ans);
}
class Inputer{constructor(t){if(typeof t=='undefined')throw new Error('引数（stdin）を省略できません！');this.cnt=0,this.items=t.split(/\n|\s/)}getInt(){return this.items[this.cnt++]-0}getIntArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getInt();return r}getStr(){return this.items[this.cnt++]}getStrArray(t){if(typeof t=='undefined')throw new Error('引数（1以上）を省略できません！');let r=new Array(t);for(let e=0;e<t;e++)r[e]=this.getStr();return r}}
if (typeof window == "undefined") Main(require("fs").readFileSync("/dev/stdin", "utf8"));