#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--) #define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--) #define fi first #define se second #define vi vector #define pb push_back #define mp make_pair #define pcnt __builtin_popcount typedef long long ll; const double inf = 900900900100.0; const int MOD = (int)1e9 + 7; const double EPS = 1e-9; templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> s; int res = 0; bool flag = false; rep(i,s.size()) { if(s[i] == '-') flag = true; if(s[i] == '+') flag = false; if(s[i]>='0' && s[i]<='9'){ if(flag) res -= (int)(s[i]-'0'); else res += (int)(s[i]-'0'); flag = false; } if (s[i] == '('){ int tmp; bool fflag = false; if(s[i+1]=='-') { fflag = true; i++; } if(s[i+2]==')') { if(fflag) flag!=flag; continue; } if(s[i+2]=='+'){ tmp = (fflag?-1:1)*(s[i+1]-'0')+(s[i+3]-'0'); } if(s[i+2]=='-'){ tmp = (fflag?-1:1)*(s[i+1]-'0')-(s[i+3]-'0'); } if(flag) res-=tmp; else res += tmp; flag = false; i+=4; } } cout << res << endl; return 0; }