n, k = gets.split(' ')
a = gets.split(' ').map(&:to_i)
array = []
n = n.to_i
len = k.to_i.to_s(2).length
zero = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
result = []

a.map do |h|
  array << h.to_s(2).rjust(len, '0').split('')
end

n.times.with_index do |index|
  array.each do |k|
    zero[index] = zero[index] + 1 if k[index].eql?('0')
  end
end

n.times.with_index do |index|
  if zero[index] > n / 2
    result << 1
  elsif zero[index] < n / 2
    result << 0
  elsif zero[index] == n / 2
    result << 2
  end
end

kakutei = []
n.times{kakutei << 0}

result.each.with_index do |res, index|
  if res == 1
    kakutei[index] = 1
  elsif res == 0
    kakutei[index] = 0
  elsif res == 2
    kakutei[index] = 1
    if kakutei.join.to_i(2) > k.to_i
      kakutei[index] = 0
    end
  end
end

kekka = 0

kakutei.each.with_index do |kak,i|
 kekka = kekka + nnn
end
puts kekka
