#include using namespace std; int main() { // 1. 入力情報取得. string S; cin >> S; // 2. 数式を生成する. int l = S.size(); // S を くっつけて, 筒化する. S += S; vector ans; // 変数 i で, 計算のスタート地点とする. for(int i = 0; i < l; i++){ string f = S.substr(i, l); // 最初と最後が演算子になってはいけないことに注意. if(f[0] == '+' || f[0] == '-' || f[l - 1] == '+' || f[l - 1] == '-') continue; // 数式を作成. vector v; v.push_back({f[0]}); for(int j = 1; j < l; j++){ int vSize = v.size(); string x = v[vSize - 1]; // cout << "x=" << x << " vSize=" << vSize << endl; if(f[j] == '+' || f[j] == '-') v.push_back({f[j]}); if(f[j] != '+' && f[j] != '-'){ if(x != "+" && x != "-") v[vSize - 1] += {f[j]}; else v.push_back({f[j]}); } } // 数式を計算. int calc = stoi(v[0]); string sign = ""; for(int i = 1; i < v.size(); i++){ string p = v[i]; // cout << "p=" << p << endl; if(p != "+" && p != "-"){ int num = stoi(p); if(sign == "+") calc += num; if(sign == "-") calc -= num; }else{ sign = p; } } ans.push_back(calc); } // 3. 出力. sort(ans.begin(), ans.end(), greater()); // for(auto &p : ans) cout << p << endl; cout << ans[0] << endl; return 0; }