def lscan; gets.split.map(&:to_i); end a,b = lscan if a == b p 1 exit end x = a&(b^((1 << 32)-1)) if x != 0 p 0 exit end u = b&(a^((1 << 32)-1)) c = u.to_s(2).count('1') p 1 << (c-1) # (0..127).each do |x| # (x..128).each do |y| # if x&y == a && x|y == b # p [x, y] # end # end # end