a1,a2,a3:string;
s,x,y,t,s1,s2:longint;
begin
readln(a);
repeat
s:=pos('*',a);
if s=0 then continue;
x:=s-1;
y:=s+1;
while (a[x-1]<>'+') and (a[x-1]<>'*') and (x-1>0) do dec(x);
while (a[y+1]<>'+') and (a[y+1]<>'*') and (y+1<=length(a)) do inc(y);
a1:=copy(a,x,s-x);
a2:=copy(a,s+1,y-s);
delete(a,x,y-x+1);
a4:=copy(a,x,length(a)-x+1);
delete(a,x,length(a)-x+1);
delete(a1,1,length(a1)-4);
delete(a2,1,length(a2)-4);
val(a1,s1);
val(a2,s2);
t:=s1*s2 mod 10000;
str(t,a3);
a:=a+a3+a4;
until s=0;
a:=a+'+';
t:=0;
repeat
s:=pos('+',a);
a1:=copy(a,1,s-1);
delete(a1,1,length(a1)-4);
delete(a,1,s);
val(a1,s1);
t:=(t+s1) mod 10000;
until a='';
str(t,a3);
writeln(a3);
end.
using namespace std;
int s[100005];
int main(){
int sh;
char k;int f;
int top=1;
cin>>sh;
s[top]=sh;
while(cin>>k){
cin>>f;
if(k=='*'){
s[top]*=f;
s[top]=s[top]%10000;
}
if(k=='+'){
top++;
s[top]=f;
s[top]=s[top]%10000;
}
}
int h=0;
for(int i=1;i<=top;i++){
h=h+s[i];
h%=10000;
}cout<<h<<endl;
return 0;
}