#include<bits/stdc++.h>
using namespace std;
stack<char> q;
stack<long long> n;
int main()
{
string s;
cin>>s;
long long a=0;
q.push('#');
bool flag=0;
for(int i=0;i<s.size();++i)
{
if(s[i]>='0'&&s[i]<='9')
{
a*=10;
a+=s[i]-'0';
a%=10000;
}
else
{
n.push(a);
a=0;
if(flag)
{
long long b=n.top();
n.pop();
b*=n.top();
n.pop();
b%=10000;
n.push(b);
flag=0;
}
if(s[i]=='*')
{
flag=1;
}
q.push(s[i]);
}
}
n.push(a);
if(flag)
{
long long b=n.top();
n.pop();
b*=n.top();
n.pop();
b%=10000;
n.push(b);
flag=0;
}
long long ans=n.top();
n.pop();
while(q.top()!='#')
{
ans+=n.top();
if(!n.empty())
n.pop();
q.pop();
ans%=10000;
}
cout<<ans<<endl;
return 0;
}