#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define mp make_pair #define pb push_back #define all(x) (x).begin(),(x).end() #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef vector vb; typedef vector vi; typedef vector vvb; typedef vector vvi; typedef pair pii; const int INF=1<<29; const double EPS=1e-9; const int dx[]={1,0,-1,0},dy[]={0,-1,0,1}; bool isenzansi(string &s, int pos) { return s[pos] == '+' || s[pos] == '-'; } int ev(string &s) { if (isenzansi(s, 0) || isenzansi(s, s.size() - 1)) { return -1; } int p = 0; int now = 0; int ret = 0; char nextop = '+'; while(p < s.size()) { if (!isenzansi(s, p)) { now *= 10; now += s[p] - '0'; } else if (s[p] == '+') { if (nextop == '+') { ret += now; } else { ret -= now; } nextop = '+'; now = 0; } else if (s[p] == '-') { if (nextop == '+') { ret += now; } else { ret -= now; } nextop = '-'; now = 0; } p++; } if (nextop == '+') { ret += now; } else { ret -= now; } return ret; } int main(int argc, char const *argv[]) { string s; cin >> s; s += s; int ans = -1; for (int i = 0; i < s.size() / 2; ++i) { string now = s.substr(i, s.size() / 2); int ret = ev(now); ans = max(ans, ret); } cout << ans << endl; return 0; }