#include #include #include #include #include static inline int eval(std::istringstream& ss) noexcept { int x = 0; char op = '\0'; for (auto ch = ss.get(); ch != EOF; ch = ss.get()) { switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': if (op == '\0') { x = ch - '0'; } else { auto y = ch - '0'; if (op == '+') { x += y; } else { x -= y; } } break; case '+': case '-': op = static_cast(ch); break; case '(': if (op == '\0') { x = eval(ss); } else { if (op == '+') { x += eval(ss); } else { x -= eval(ss); } } break; case ')': return x; } } return x; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::string s; std::cin >> s; std::istringstream ss(s); std::cout << eval(ss) << std::endl; return EXIT_SUCCESS; }