#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; typedef vector vl; typedef pair pll; typedef vector > vpll; typedef vector vs; typedef long double ld; template inline void amin(T &x, U y) { if (y < x) x = y; } template inline void amax(T &x, U y) { if (x < y) x = y; } namespace parse { typedef const char *Pos; struct ParseError { Pos p_; std::stringstream *ss_; ParseError(const Pos &p) : p_(p), ss_(new std::stringstream()) { } ParseError(const ParseError &that) : p_(0), ss_(0) { *this = that; } ParseError &operator=(const ParseError &that) { delete ss_; p_ = that.p_; ss_ = new std::stringstream(that.ss_->str()); return *this; } ~ParseError() { delete ss_; } template ParseError &operator<<(const T &t) { *ss_ << t; return *this; } friend std::ostream &operator<<(std::ostream &o, const ParseError &e) { o << e.ss_->str() << " at: "; Pos q = e.p_; for (int k = 0; *q && k < 20; ++q, ++k) o << *q; if (*q) o << "..."; else o << "(end of input)"; return o; } }; inline bool cond(bool b, Pos &p) { if (b) ++p; return b; } inline bool rewind(int k, bool b, Pos &p) { if (!b) p -= k; return b; } inline bool rw0(bool b, Pos &p) { return b; } inline bool rw1(bool b, Pos &p) { return rewind(1, b, p); } inline bool rw2(bool b, Pos &p) { return rewind(2, b, p); } inline bool optional(bool) { return true; } inline bool expect(bool b, const Pos &p) { if (!b) throw ParseError(p) << "parse error"; return b; } inline bool char_(char c, Pos &p) { return cond(c == *p, p); } inline bool string_(const char *str, Pos &p) { Pos o = p; for (const char *s = str; *s; ++s, ++p) { if (*s != *p) { p = o; return false; } } return true; } }; using namespace parse; bool natural(Pos &p, int &res) { if (!isdigit(*p)) return false; int c = 0; while (isdigit(*p)) { c = c * 10 + (*p - '0'); ++p; } res = c; return true; } bool expr(Pos &p, int &res) { if(!natural(p, res)) return false; while (*p == '+' || *p == '*') { char op = *p; ++p; int operand; expect(natural(p, operand), p); if (op == '+') res *= operand; else res += operand; } return true; } int main() { char *S = new char[101]; scanf("%s", S); Pos p = S; int res; expr(p, res); cout << res << endl; return 0; }