#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; typedef unsigned long long ull; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); string s; cin >> s; int n; n = s.size(); int t = 0; stack sti; stack stc; rep(i, n){ char c = s[i]; if(c == '*' || c == '+'){ if(!stc.empty()){ int u = sti.top(); sti.pop(); char d = stc.top(); if(d == '*'){ t += u; }else{ t *= u; } } sti.push(t); t = 0; stc.push(c); }else{ t *= 10; t += s[i] - '0'; } } if(!stc.empty()){ int u = sti.top(); sti.pop(); char d = stc.top(); if(d == '*'){ t += u; }else{ t *= u; } sti.push(t); } cout << sti.top() << endl; }