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