#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef pair pls; int main() { string S; cin >> S; int S_size = S.size(); S = S + S; ll ans = -100000000000; for (int i = 0; i < S_size; i++) { string str = ""; for (int j = i; j < S_size+i; j++) { if (j == i || j == S_size + i-1) { if (S[j] < '0' || S[j] > '9')break; } str += S[j]; } ll sum = 0; if (str.size() == S_size) { string figure = "",ope = "+"; for (int j = 0; j < str.size(); j++) { if (str[j] >= '0' && str[j] <= '9') { figure += str[j]; } else{ if (ope == "+") sum = sum + stoll(figure); else if(ope == "-") sum = sum - stoll(figure); ope = str[j]; figure = ""; } if (j == str.size() - 1) { if (ope == "+") { sum = sum + stoll(figure); } else if (ope == "-") sum = sum - stoll(figure); ope = str[j]; } } } if(sum != 0) ans = max(ans,sum); } cout << ans << endl; return 0; }