# include # ifndef ngng628_library # define ngng628_library # define int Int # define float Float # define overload3(_1,_2,_3,name,...) name # define _step(n) _rep(_,n) # define _rep(i,n) _repr(i,0,n) # define _repr(i,b,e) for(int i=(b), i##_len=(e); i=0; --i) # define rreps(i,n) for(int i=(n); i>0; --i) # define all(v) std::begin(v), std::end(v) # define rall(v) std::rbegin(v), std::rend(v) # define pb push_back # define eb emplace_back # define len(v) (int)std::size(v) # define eprintf(...) fprintf(stderr, __VA_ARGS__) using namespace std; using Int = long long; using Float = long double; template using vec = vector; using pii = pair; using vi = vec; using vvi = vec; using db = deque; using ddb = deque; constexpr int oo = (1LL<<62)-(1LL<<31); template istream& operator >>(istream& is, vec& v) { for (auto& x : v) is >> x; return is; } template istream& operator >>(istream& is, array& v) { for (auto& x : v) is >> x; return is; } template istream& operator >>(istream& is, pair& p) { return is >> p.first >> p.second; } template string join(const vec& v){ stringstream s; for (T t : v) s << ' ' << t; return s.str().substr(1); } template ostream& operator <<(ostream& os, const vec& v){ if (len(v)) os << join(v); return os; } template ostream& operator <<(ostream& os, const vec>& v){ rep (i, len(v)) if (len(v[i])) os << join(v[i]) << (i-len(v)+1 ? "\n" : ""); return os; } template ostream& operator <<(ostream& os, const pair& p){ return os << p.first << ' ' << p.second; } template ostream& operator <<(ostream& os, const tuple& t){ return os << get<0>(t) << " " << get<1>(t) << " " << get<2>(t); } template constexpr bool chmax(T& a, const T& b){ return a < b && (a = b, true); } template constexpr bool chmin(T& a, const T& b){ return a > b && (a = b, true); } # endif // ngng628_library using State = string::const_iterator; void skip(State& it) { while (isspace(*it)) ++it; } void skip(State& it, const string& s) { rep (i, len(s)) { assert(s[i] == *it); ++it; } } void skip(State& it, int n) { while (n--) ++it; } string erase_all_space(string s) { s.erase(remove_if(all(s), [](char c){ return isspace(c); }), s.end()); return s; } int32_t main() { string s; cin >> s; struct Parser { string s; Parser(string _s) : s(_s) {} int exec() { State begin = s.begin(); return expr(begin); } int expr(State& it) { int res = term(it); while (true) { if (*it == '+') res += term(++it); else if (*it == '-') res -= term(++it); else break; } return res; } int term(State& it) { if (*it == '(') { int res = expr(++it); skip(it, ")"); return res; } else { // isdigit(*it) return number(it); } } int number(State& it) { int res = 0; while (isdigit(*it)) { res *= 10; res += *it - '0'; ++it; } return res; } }; cout << Parser(s).exec() << endl; }