#include<cstdio>
#include<stack>
using namespace std;
stack<int> num;
long long ans=0;
int a;
char b;
int main(){
scanf("%d",&a);
num.push(a);
while(scanf("%c",&b)!=EOF){
scanf("%d",&a);
if(b=='*'){
int l=num.top();
num.pop();
num.push(l*a);
}
else{
num.push(a);
}
}
while(!num.empty()){
ans+=num.top();
num.pop();
}
printf("%lld",ans%10000);
return 0;
}