use std::cmp;
use std::collections::HashMap;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        n: usize,
        k: u64,
        a: [u64;n]
    }

    // 全てのa_nの各bitの総和
    let mut bits: Vec<u64> = vec![0; 64];

    for i in 0..n {
        for b in 0..64 {
            if (a[i] >> b) & 1 == 1 {
                bits[b] += 1;
            }
        }
    }

    let mut k_bit: Vec<u64> = vec![0; 64];
    for b in 0..64 {
        k_bit[b] += (k >> b) & 1;
    }

    //println!("{:?}", bits);
    //println!("{:?}", k_bit);

    let mut ans = 0;
    // iの値を0にする
    for i in (0..60).rev() {
        let mut ans_tmp = 0;
        if k_bit[i] == 1 {
            for b in (0..60).rev() {
                let base = (2 as u64).pow(b as u32);
                if b < i {
                    ans_tmp += cmp::max(n as u64 - bits[b], bits[b]) * base;
                } else if b == i {
                    ans_tmp += bits[b] * base;
                } else {
                    if k_bit[b] == 1 {
                        ans_tmp += (n as u64 - bits[b]) * base;
                    } else {
                        ans_tmp += bits[b] * base;
                    }
                }
            }
        }
        ans = cmp::max(ans, ans_tmp);
    }

    let mut tmp = 0;
    for b in (0..60).rev() {
        let base = (2 as u64).pow(b as u32);
        if k_bit[b] == 1 {
            tmp += (n as u64 - bits[b]) * base;
        } else {
            tmp += bits[b] * base;
        }
    }
    ans = cmp::max(ans, tmp);

    println!("{:?}", ans);
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 8572