#include #define REP(i,n,N) for(int i=(n);i<(int) N;i++) #define p(s) cout<<(s)<>s; int ans=0; REP(i,0,s.size()){ rotate(s.begin(),s.begin()+1,s.end()); if(!isdigit(s[0])||!isdigit(s.back())) continue; int tmp=0; int mx=0; bool hugo=0; bool number=0; REP(j,0,s.size()){ if(isdigit(s[j])){ tmp*=10; tmp+=s[j]-'0'; number=1; }else { if(number==0){ mx=0; break; }else if(hugo==0) mx+=tmp; else mx-=tmp; tmp=0; if(s[j]=='+') hugo=0; else if(s[j]=='-') hugo=1; } } if(number){ if(hugo==0) mx+=tmp; else mx-=tmp; } ans=max(ans,mx); } p(ans); return 0; }