local str = io.read() local n = #str local sstr = "" local function parse(a) local sum = 0 local flg = 1 if(a:sub(n, n) == "+" or a:sub(n, n) == "-") then return false, 0 end if(a:sub(1, 1) == "+" or a:sub(1, 1) == "-") then return false, 0 end local pos = 1 local va = 0 while(pos ~= nil) do st, ed = a:find("%d+", pos) if(st == nil) then pos = nil else va = tonumber(a:sub(st, ed)) sum = sum + flg * va if(ed == n) then pos = nil else if(a:sub(ed + 1, ed + 1) == "+") then flg = 1 else flg = -1 end pos = ed + 2 end end end return true, sum end local xma = nil for ofst = 0, n - 1 do if(0 < ofst) then sstr = str:sub(ofst + 1, n) .. str:sub(1, ofst) else sstr = str end local ret1, ret2 = parse(sstr) if(ret1) then if(xma == nil) then xma = ret2 else xma = math.max(xma, ret2) end end end print(xma)