#include <bits/stdc++.h>
using namespace std;
stack <char> st;
stack <int> st1;
string a,b;
int num(char n){
if(n=='+')return 1;
if(n=='-')return 1;
if(n=='*')return 2;
if(n=='/')return 2;
}
int main(){
cin>>a;
int lena,lenb,flag=0,x=0,i=0;
lena=a.length();
while(i<lena){
while(a[i]>='0'&&a[i]<='9'){
b=b+a[i];
i++;
}
b=b+' ';
if(a[i]=='+'||a[i]=='-'||a[i]=='*'||a[i]=='/'){
if(st.empty()){
st.push(a[i]);
}
else if(num(a[i])>num(st.top())){
st.push(a[i]);
}
else{
while(!st.empty()&&num(a[i])<=num(st.top())){
b=b+st.top();
b=b+' ';
st.pop();
}
st.push(a[i]);
}
}
i++;
}
while(!st.empty()){
b=b+st.top();
b=b+' ';
st.pop();
}
lenb=b.length();
int s1,s2;
i=0;
while(i<lenb){
while(b[i]>='0'&&b[i]<='9'){
if(flag==0){
x=(int)(b[i]-'0');
flag=1;
}else{
x=x*10+(int)(b[i]-'0');
}
i++;
}
if(b[i]==' '&&flag==1){
st1.push(x);
flag=0;
}
i++;
if(b[i]=='+'||b[i]=='-'||b[i]=='*'||b[i]=='/'){
s2=st1.top();
st1.pop();
s1=st1.top();
st1.pop();
if(b[i]=='+'){
st1.push(s1+s2);
}else if(b[i]=='-'){
st1.push(s1-s2);
}else if(b[i]=='*'){
st1.push(s1*s2);
}else{
st1.push(s1/s2);
}
i++;
}
}
cout<<st1.top()%10000;
}