A, B = gets.split.map(&:to_i) bits_a = [] bits_b = [] A.to_s(2).rjust(32, '0').reverse.each_char.with_index do |ch, idx| next if ch == '0' bits_a << idx end B.to_s(2).rjust(32, '0').reverse.each_char.with_index do |ch, idx| next if ch == '0' bits_b << idx end a = (bits_a & bits_b).size b = bits_b.size - a c = (bits_a - bits_b).size # p [:bits_a, bits_a] # p [:bits_b, bits_b] # p [:a, a, :b, b, :c, c] if c > 0 puts 0 elsif b == 0 puts 1 else puts (2 ** b) / 2 end