#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define llong long long int calc(int ee, char op, int er) { if(op == '-') return ee - er; return ee + er; } int getval(string s, int start, int len) { int result = 0; string er = ""s; char op = 'a'; rep(i, len) { if(s[start+i] == '+') { if(op == 'a') result += stoi(er); else result = calc(result, op, stoi(er)); er = ""s; op = '+'; } else if(s[start+i] == '-') { if(op == 'a') result += stoi(er); else result = calc(result, op, stoi(er)); er = ""s; op = '-'; } else { er += s[start+i]; } } result = calc(result, op, stoi(er)); return result; } int main() { string s; cin >> s; int len = s.length(); s += s; int result = -1e9; rep(i, len) { if(s[i] == '+' || s[i] == '-') continue; if(s[i+len-1] == '+' || s[i+len-1] == '-') continue; result = max(result, getval(s, i, len)); } cout << result << "\n"; }