N, K = gets.strip.split(/\s+/).map(&:to_i)
As = gets.strip.split(/\s+/).map(&:to_i)
num1bit = [0]*40
40.times{|i|
	num1bit[39-i] = As.count{|a| (a>>i)&1 == 1 }
}
f, k, w = 0, 0, 2**40
num1bit.each{|n1| w /= 2
	if N/2 < N-n1 and k+w <= K
		f += (N-n1) * w
		k += w
	else
		f += n1 * w
	end
}
puts f
