open Printf
open Scanf

let (++) = Int64.add
let (--) = Int64.sub
let lnotl = Int64.lognot
let landl = Int64.logand
let lorl = Int64.logor
let lxorl = Int64.logxor
let lsll = Int64.shift_left

let read_int _ = bscanf Scanning.stdin " %d " (fun x -> x)
let read_long _ = bscanf Scanning.stdin " %Ld " (fun x -> x)

let bit_cnt cnt v =
  let rec bit_cnt' i =
      if i >= 60
      then ()
      else
        let () = cnt.(i) <- (cnt.(i) + if landl v (lsll 1L i) <> 0L then 1 else 0) in
        bit_cnt' (i+1) in
  bit_cnt' 0

let collect n cnt =
  let rec collect' i v =
    if i >= 60
    then v
    else
      let v' = if cnt.(i)*2 < n then lorl v (lsll 1L i) else v in
      collect' (i+1) v' in
  collect' 0 0L

let msb b =
  let rec msb' c = function
    | i when i >= 60 -> c
    | i -> if landl b (lsll 1L i) <> 0L then msb' i (i+1) else msb' c (i+1) in
  msb' 0 0

let rec foldi i n accum f =
  if i > n
  then accum
  else foldi (i+1) n (f accum i) f

let off b i = landl b @@ lnotl @@ lsll 1L i

let () =
  let n = read_int () in
  let k = read_long () in
  let a = Array.init n read_long in
  let cnt = Array.make 60 0 in
  Array.iter (bit_cnt cnt) a;
  let x = collect n cnt in
  let m = msb k in
  let k' = lsll 1L (m + 1) -- 1L in
  let calc x = Array.fold_left (fun a b -> a ++ (lxorl b x)) 0L a in
  let r = foldi 0 m (calc (landl k x)) (fun accum i -> max accum (calc (off k' i))) in
  printf "%Ld\n" r
