program expr;
var
bds:ansistring;
shuzi:array [1..100001] of longint;
zifu:array [0..100000] of char;
k:array [1..50000] of longint;
i,l,n,hehe,j,a,ps:longint;
f:string;
begin
assign(input,*expr.in*);
reset(input);
assign(output,*expr.out*);
rewrite(output);
n:=0;
i:=0;
l:=1;
hehe:=0;
zifu[0]:=*+*;
readln(bds);
while bds<>** do
begin
inc(i);
a:=pos(*+*,bds);
ps:=pos(***,bds);
if ((a > ps) or (a=0)) and (ps<>0) then a:=ps;
f:=bds;
delete(f,a,length(f));
val(f,shuzi[i]);
n:=length(f)+1;
zifu[i]:=bds[n];
delete(bds,1,n);
end;
for j:= 1 to i do
begin
if(zifu[j]=***) and (zifu[j-1]=*+*) then
begin
inc(l);
k[l]:=shuzi[j]*shuzi[j+1];
end
else if (zifu[j]=***) and (zifu[j-1]=***) then k[l]:=k[l]*shuzi[j+1]
else if zifu[j-1]=*+* then
begin
inc(l);
k[l]:=shuzi[j];
end;
end;
for j:= 1 to l do inc(hehe,k[j]);
hehe:=hehe mod 10000;
writeln(hehe);
readln;
close(input);
close(output);
end.