#include #include #include #include #include #include #include #include #include #define REP(i,k,n) for(int i=k;i P; vector split(const string &str, char delim) { vector res; size_t current = 0, found; while((found = str.find_first_of(delim, current)) != string::npos) { res.push_back(string(str, current, found - current)); current = found + 1; } res.push_back(string(str, current, str.size() - current)); return res; } int main() { string s; cin >> s; ll ans = 0; rep(i,s.size()) { rotate(s.begin(),s.begin()+1,s.end()); if(s[0] == '+' || s[0] == '-' || s[s.size()-1] == '+' || s[s.size()-1] == '-') { continue; } vector v; stringstream ss; rep(i,s.size()) { if(s[i] == '+') { v.push_back(ss.str()); v.push_back("+"); ss.str(""); ss.clear(stringstream::goodbit); } else if(s[i] == '-') { v.push_back(ss.str()); v.push_back("-"); ss.str(""); ss.clear(stringstream::goodbit); } else { ss << s[i]; } } v.push_back(ss.str()); ll res = 0; bool p = true; rep(i,v.size()) { if(v[i] == "+") { p = true; } else if(v[i] == "-") { p = false; } else { ll t; stringstream ss; ss << v[i]; ss >> t; if(p) res += t; else res -= t; } } ans = max(ans,res); } cout << ans << endl; return 0; }