def lscan; gets.split.map(&:to_i); end a,b = lscan 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)