function main(input) {
  var rows = input.split('\n');
  var K = rows[0].split(" ").map(Number)[1];
  var numbers = rows[1].trim().split(" ").map(Number);
  var max = 0;
  for (var i = 0; i<= K; i++) {
    max = Math.max(max, numbers.reduce((sum, cur) => sum + (i^cur), 0))
  }

  console.log(max);
}

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