#include<iostream>
#include<string>
#include<stack>
#include<cctype>
using namespace std;
const int N(10000);
stack<int> data;
stack<char> opr;
string s;
int ans(0);
int cal() //数据栈出两数据,符号栈出运算符号,进行相应运算
{
int x,y;
char ch;
x=data.top(); data.pop();
y=data.top(); data.pop();
ch=opr.top(); opr.pop();
switch (ch)
{
case '+': data.push((x%N+y%N)%N); break;
case '*': data.push((x%N)*(y%N)%N); break;
}
}
void solve()
{
int x,len(s.size());
x=0;
for (int i=0;i<len;)
{
if (isdigit(s[i]))
{
while (i<len&&isdigit(s[i]))
x=x*10+(int)s[i++]-48;
data.push(x%N);
x=0;
}
else
switch (s[i++])
{
case '+': while (!opr.empty()) cal();
opr.push('+');
break;
case '*': while (!opr.empty()&&opr.top()=='*') cal();
opr.push('*');
break;
}
}
while (!opr.empty()) cal();
}
int main()
{
//ifstream cin("expr.in");
//ofstream cout("expr.out");
cin>>s;
solve();
cout<<data.top()<<endl;
return 0;
}
/**************************************************************
Problem: 2321
User: admin
Language: C++
Result: Accepted
Time:81 ms
Memory:3604 kb
****************************************************************/