#include #include #include using namespace std; using State = string::const_iterator; class ParseError{}; // ::= ("0"|"1"|"2"|"3"|"4"|"5"|"6"|"7"|"8"|"9") // ::= | // ::= | ("+"|"-") | "(" ")" int num(State &begin){ int ret = 0; while(isdigit(*begin)){ ret *= 10; ret += *begin - '0'; begin++; } return ret; } int exp(State &begin){ int ret = num(begin); for(;;){ if(*begin == '+'){ begin++; ret += num(begin); }else if(*begin == '-'){ begin++; ret -= num(begin); }else{ break; } } return ret; } int parse(string s){ State begin = s.begin(); return exp(begin); } int main(){ string ss;cin>>ss; string s = ss+ss; int ans = 0; for(int i = 0; ss.size() > i; i++){ if('0' <= s[i] && s[i] <= '9' && '0' <= s[i+ss.size()-1] && s[i+ss.size()-1] <= '9'){ ans = max(ans,parse(s.substr(i,ss.size()))); } } cout << ans << endl; }