def max(a,b); a > b ? a : b; end

def solve_1(n,k,a)
  m = (k+1).bit_length - 1
  s = max(m, a.max.bit_length)
  cnt = Array.new(s, 0)
  s.times do |i|
    n.times do |j|
      cnt[i] += a[j][i]
    end
  end
  
  m.times do |i|
    cnt[i] = max(cnt[i], n - cnt[i])
  end
  
  ans = 0
  cnt.reverse_each do |i|
    ans *= 2
    ans += i
  end
  return ans
end

def solve_2(n,k,a)
  m = k.bit_length
  s = max(m, a.max.bit_length)
  cnt = Array.new(s, 0)
  s.times do |i|
    n.times do |j|
      cnt[i] += a[j][i]
    end
  end
  
  m.times do |i|
    if cnt[i] < n - cnt[i] && k[i] == 1
      cnt[i] = n - cnt[i]
    end
  end
  
  ans = 0
  cnt.reverse_each do |i|
    ans *= 2
    ans += i
  end
  return ans
end


n,k = gets.to_s.split.map{ |v| v.to_i }
a = gets.to_s.split.map{ |v| v.to_i }
ans = [solve_1(n,k,a), solve_2(n,k,a)].max
puts ans