#include #include #include #include #include #include using namespace std; #define CK(N, A, B) (A <= N && N < B) #define REP(i, a, b) for (int i = a; i < b; i++) #define RREP(i, a, b) for (int i = (b - 1); a <= i; i--) #define F first #define S second typedef long long ll; const int INF = 1e9 + 7; const long long LLINF = 1e18; string s; int main() { cin>>s; stack stk; REP(i, 0, s.size()){ //if(!stk.empty()) cout<<"stk:"<='0' && s[i]<='9'){ stk.push(s[i]-'0'); } else if(s[i]=='+' && s[i+1]!='('){ int x=stk.top(); stk.pop(); x+=(s[i+1]-'0'); stk.push(x); i++; } else if(s[i]=='-' && s[i+1]!='('){ int x=stk.top(); stk.pop(); x-=(s[i+1]-'0'); stk.push(x); i++; } else if(s[i]=='+' && s[i+1]=='('){ int j=i+2; stack stk2; while(s[j]!=')'){ if(s[j]>='0' && s[j]<='9'){ stk2.push(s[j]-'0'); } else if(s[j]=='+'){ int x=stk2.top(); stk2.pop(); x+=(s[j+1]-'0'); stk2.push(x); j++; } else if(s[j]=='-'){ int x=stk2.top(); stk2.pop(); x-=(s[j+1]-'0'); stk2.push(x); j++; } j++; } int x=stk.top(), y=stk2.top(); stk.pop(); x+=y; stk.push(x); i=j+1; } else if(s[i]=='-' && s[i+1]=='('){ int j=i+2; stack stk2; while(s[j]!=')'){ if(s[j]>='0' && s[j]<='9'){ stk2.push(s[j]-'0'); } else if(s[j]=='+'){ int x=stk2.top(); stk2.pop(); x+=(s[j+1]-'0'); stk2.push(x); j++; } else if(s[j]=='-'){ int x=stk2.top(); stk2.pop(); x-=(s[j+1]-'0'); stk2.push(x); j++; } j++; } //cout<<"stk2.top()="< stk2; while(s[j]!=')'){ if(s[j]>='0' && s[j]<='9'){ stk2.push(s[j]-'0'); } else if(s[j]=='+'){ int x=stk2.top(); stk2.pop(); x+=(s[j+1]-'0'); stk2.push(x); j++; } else if(s[j]=='-'){ int x=stk2.top(); stk2.pop(); x-=(s[j+1]-'0'); stk2.push(x); j++; } j++; } stk.push(stk2.top()); } } cout<