#include<bits/stdc++.h>
using namespace std;
stack<long long> s;
int main(){
long long a,c;
char b;
cin>>a;
a%=10000;
s.push(a);
while(cin>>b>>c){
if(b=='*'){
long long t=s.top();
s.pop();
s.push(c%10000*t%10000);
}
else{
s.push(c);
}
}
int sum=0;
while(s.size()){
sum+=s.top()%10000;
s.pop();
}
cout<<sum;
return 0;
}