#include <bits/stdc++.h>
using namespace std;
int n,m,i;
stack<int>s;
stack<char>c;
char a[100005];
bool x[114514];
void f(){
int sum=0;
int x=s.top();
s.pop();
int y=s.top();
s.pop();
char z=c.top();
c.pop();
if(z=='*'){
sum=x*y;
}else if(z=='+'){
sum=x+y;
}
s.push(sum%10000);
return ;
}
int main(){
cin>>a;
x['+']=1;
x['*']=2;
for(int i=0;i<strlen(a);i++){
if(a[i]>='0'&&a[i]<='9'){
int num=0,j=i+1;
while(a[j]>='0'&&a[j]<='9'){
num=num*10+a[i]-'0';
j++;
}
i=j-1;
s.push(num%10000);
}else if(a[i]=='+'){
c.push(a[i]);
}else if(a[i]=='*'){
while(!c.empty()&&x[c.top()]>x[a[i]]){
f();
}
c.push(a[i]);
}
}
while(c.empty()==0){
f();
}
cout<<s.top()%10000;
return 0;
}