#include using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); string s; cin >> s; int res{ 0 }, f{ 1 }; for (size_t i = 0; i < s.size(); ++i) { switch (s[i]) { case '(': if (i) f = s[i - 1] == '-' ? -1: 1; res += (s[i + 1] - '0') * f; ++i; continue; break; case ')': f = 1; break; case '+': case '-': { int ff = s[i] == '-' ? -1 : 1; if (s[i + 1] == '(') { res += (s[i + 2] - '0') * f * ff; f = ff; i += 2; continue; } res += (s[i + 1] - '0') * f * ff; ++i; break; } default: if (i == 0) res = s[i] - '0'; } } cout << res << "\n"; return 0; }