def cylinder array tmp = array.shift array.push(tmp) end s = gets.chomp ans = [] a = s.split('') a.size.times{ if a[0] =~ /[^+\-]/ && a[-1] =~ /[^+\-]/ t = a.join('') t.gsub!(/\d+/){ tmp = $& while tmp.length != 1 && tmp[0] == '0' tmp.slice!(0) end tmp } ans.push(eval(t)) end cylinder(a) } p ans.max