#include #include int main() { char s[101]; std::cin >> s; std::stack stk; for(int i = 0; s[i]; i++) { if((s[i] > '0') && (s[i] < '9')) s[i] -= '0'; stk.push(s[i]); } int ans = 0; int temp = 0; int sign = 0; char pop; while(!stk.empty()) { pop = stk.top(); stk.pop(); if(pop <= 9) { switch(sign) { case 0: ans = pop; break; case 1: ans += pop; break; case -1: ans = pop - ans; } sign = 0; } if(pop == '+') sign = 1; if(pop == '-') sign = -1; if(pop == ')') { temp = ans * sign; sign = 0; } if(pop == '(') { stk.push(ans); stk.push('+'); stk.push(temp); sign = 0; ans = 0; } } std::cout << ans << std::endl; return 0; }