#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long Int; #define num(x) ('0'<=x&&x<='9') int main(void){ string S; cin >> S; int n = S.size(); Int res = 0; for (int i = 0; i < n; i++){ //bool f = false; if (!num(S[i]))continue; if (!num(S[(i+n-1)%n]))continue; /* for (int j = 0; j < n - 1; j++) if (!num(S[(i+j)%n])) if (!num(S[(i+j + 1) % n])) f = true; if (f)continue;*/ Int sum = 0; string now=""; for (int j = n-1; j >= 0; j--){ switch (S[(i + j) % n]){ case '+':sum += stoll(now); now = ""; break; case '-':sum -= stoll(now); now = ""; break; default:now = S[(i + j) % n] + now; break; } } sum += stoll(now); res = max(res, sum); } cout << res << endl; return(0); }