"use strict";
function I(s,f){this._s=s.split("\n");this._c=0;this._l=0;this._f=f||Number}I.prototype.a=function(){var l=this._s[this._l];if(!l)return;var t=l.trim().split(" ");var a=t[this._c];this._c++;if(t.length===this._c){this._c=0;this._l++}return this._f(a)};I.prototype.l=function(){var l=this._s[this._l];if(!l)return;this._c=0;this._l++;return l.split(" ").map(this._f)};
function xor(r,o){for(var a=1073741824,f=r,t=o,n=0;f>a||t>a;){var h=Math.floor(f/a),l=Math.floor(t/a);n+=h^l,n*=a,f-=h*a,t-=l*a}return n+=f^t}

function main(input) {
  var o = new I(input);

  var n = o.a();
  var k = o.a();
  var a = o.l();

  var max = Math.max(...a, k);
  var strMax = max.toString(2);

  var l = strMax.length;
  var strA = a.map(x => {
    var strX = x.toString(2);
    while (strX.length < l) {
      strX = "0" + strX;
    }
    return strX;
  });

  var perfect = "";
  for (var i = 0; i < l; i++) {
    var zero = 0;
    var one = 0;
    strA.forEach(stra => {
      if (stra[i] === "0") {
        zero += 1;
      } else {
        one += 1;
      }
    });
    if (zero > one) {
      perfect += "1";
    } else {
      perfect += "0";
    }
  }

  var strK = k.toString(2);
  var tries = [k];
  for (var i = 0; i < strK.length; i++) {
    if (strK[i] === "1") {
      var temp = strK.slice(0, strK.length - i - 1) + "0" + perfect.slice(perfect.length - i, perfect.length);
      tries.push(parseInt(temp, 2));
    }
  }

  var ans = 0;
  tries.forEach(x => {
    var temp = a.reduce((acc, cur) => {
      return acc + xor(cur, x)
    }, 0)
    if (temp > ans) {
      ans = temp;
    }
  })

  console.log(ans.toString());
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));
