s = gets.chomp matches = s.match(/(?x)?(?\d+)/) num = matches[:num].to_i t = matches[:prefix] ? 2**32 - num : num puts t