#include using namespace std; int dfs(string str) { stack s; stack c; int score = 0; char nowc = '+'; for (int i = 0; i < str.size(); i++) { if (str[i] == '(') { for (int j = i + 1; j < str.size(); j++) { if (str[j] == '(') { s.push(j); } if (str[j] == ')') { if (s.size()) { s.pop(); continue; } switch (nowc) { case '+': score += dfs(str.substr(i + 1, j - i - 1)); break; case '-': score -= dfs(str.substr(i + 1, j - i - 1)); } i = j; } } } else if (str[i] == '+' || str[i] == '-') { nowc = str[i]; } else { switch (nowc) { case '+': score += str[i] - '0'; break; case '-': score -= str[i] - '0'; break; } } } return score; } void hawawa() { string str; cin >> str; cout << dfs(str) << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(0); hawawa(); return 0; }