#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef vector vi; typedef pair pii; typedef vector vpii; #define fst first #define scd second #define PB push_back #define MP make_pair #define rep(i,x) for(int i=0;i<(x);++i) #define rep1(i,x) for(int i=1;i<=(x);++i) #define rrep(i,x) for(int i=(x)-1;i>=0;--i) #define rrep1(i,x) for(int i=(x);i>=1;--i) #define FOR(i,a,x) for(int i=(a);i<(x);++i) #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define omajinai ios::sync_with_stdio(false);cin.tie(0) templatebool chmax(T&a,T b){if(abool chmin(T&a,T b){if(a>b){a=b;return true;}return false;} templateT get(){T a;cin>>a;return a;} templateT rev(T a){reverse(all(a));return a;} templateistream&operator>>(istream&is,vector&vec){rep(i,vec.size())is>>vec[i];return is;} templatevector&sort(vector&a){sort(all(a));return a;} const int inf = 1e9; const ll linf = 3e18; const double eps = 1e-9; int calc(string s) { s += '+'; int res = 0; int tmp = 0; char op = '+'; rep(i, s.size()) { if (isdigit(s[i])) { tmp *= 10; tmp += s[i] - '0'; } else { if (op == '+') { res += tmp; } else { res -= tmp; } tmp = 0; op = s[i]; } } return res; } signed main() { string expr; cin >> expr; int N = expr.size(); expr += expr; int ma = 0; rep(i, N) { string a = expr.substr(i, N); if (!isdigit(a[0]) || !isdigit(a[a.size() - 1])) continue; ma = max(ma, calc(a)); } cout << ma << endl; }