import std.algorithm, std.array, std.container, std.range, std.bitmanip; import std.numeric, std.math, std.bigint, std.random; import std.string, std.conv, std.stdio, std.typecons; void main() { auto s = readln.chomp; auto r = iota(s.length) .map!(i => s[i..$] ~ s[0..i]) .filter!(s => s.front != '+' && s.front != '-' && s.back != '+' && s.back != '-') .map!(calc) .reduce!(max); writeln(r); } int calc(string s) { auto acc = 0, buf = 0; char op; foreach (c; s) { if (c >= '0' && c <= '9') { buf = buf * 10 + (c - '0'); } else if (c == '+' || c == '-') { applyOp(acc, buf, op); op = c; } } applyOp(acc, buf, op); return acc; } void applyOp(ref int acc, ref int buf, ref char op) { if (op == '+') { acc = acc + buf; } else if (op == '-') { acc = acc - buf; } else { acc = buf; } buf = 0; }