class Yukicoder def initialize s = gets.chomp list = s.chars max_val = -Float::INFINITY 0.upto(s.size-1) do |n| begin a = list.rotate(n).join if a =~ /^\d.*\d$/ val = eval(a.split(/(\+|-)/).map{|n| if n =~ /\d+/ n.to_i(10) else n end }.join) max_val = [max_val, val].max end rescue => ex end end puts max_val end end Yukicoder.new