#define _CRT_SECURE_NO_WARNINGS #include #include #include #include #include #include #include #include #include #include #include #include #include //#include "util.h" using namespace std; typedef long long lint; typedef unsigned long long ull; typedef pair Pii; #define PI 3.14159265358979323846 #define EPS 1e-6 #define MOD ((lint)1000000007) #define MIN(a,b) ((a)<(b)?(a):(b)) #define MAX(a,b) ((a)>(b)?(a):(b)) #define CHAR_BIT 8 template ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; } cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; } class calc { private: string S; int pos; enum op { MUL, ADD }; public: calc(string S) { this->S = S; pos = 0; } calc(string S, int pos) { this->S = S; this->pos = pos; } void syntax_error(string S) { cout << S << endl; exit(EXIT_FAILURE); } int parse_int() { if (S[pos] < '0' || '9' < S[pos]) syntax_error("parse_int"); int res = 0; while (pos < S.size() && '0' <= S[pos] && S[pos] <= '9') { res *= 10; res += S[pos] - '0'; pos++; } return res; } op parse_operator() { if (S[pos] == '*') { pos++; return ADD; } else if (S[pos] == '+') { pos++; return MUL; } else syntax_error("parse_operator"); } int calculate() { int res = parse_int(); while (pos != S.size()) { op o = parse_operator(); if (o == ADD) res += parse_int(); else res *= parse_int(); } return res; } }; int yuki0044() { string S; cin >> S; cout << calc(S).calculate() << endl; return 0; } int main() { //clock_t start, end; //start = clock(); yuki0044(); //end = clock(); //printf("%d msec.\n", end - start); return 0; }