class Yukicoder def initialize s = gets.chomp s = s.gsub(/(\d+\*\d+)|(\+\d+)/){ if $&['*'] '('+$&.gsub('*','+')+')' else $&.gsub('+','*') end } puts eval(s) end end Yukicoder.new