#include<bits/stdc++.h>
using namespace std;
string s;
int cur;
stack<int>sv;
stack<int>so;
void calc()
{
int a,b;
int op=so.top();
if(op==1)
{
b=sv.top();
sv.pop();
a=sv.top();
sv.pop();
a%=10000;
b%=10000;
sv.push((a+b)%10000);
}
if(op==2)
{
b=sv.top();
sv.pop();
a=sv.top();
sv.pop();
a%=10000;
b%=10000;
sv.push((a*b)%10000);
}
so.pop();
}
int main(void)
{
cin>>s;
for(int i=1;i<=s.size();i++)
{
if(s[i]>='0'&&s[i]<='9')
{
cur=cur*10+s[i]-'0';
}
if(s[i]=='+')
{
sv.push(cur);
cur=0;
//一直计算到符号栈为空
while(!so.empty())
{
calc();
}
//左边全部计算
so.push(1);
}
if(s[i]=='*')
{
sv.push(cur);
cur=0;
while(!so.empty()&&so.top()>=2)
{
calc();
}
so.push(2);
//计算左边所有乘法
}
else
{
sv.push(cur);
cur=0;
}
}
while(!so.empty())
{
calc();
}
cout<<sv.top();
return 0;
}