var i,j,n,m,k,o,p:longint;
s:ansistring;
function try(s:ansistring;z:longint):longint;
var ans1,ans2,l,i,j,k,pd:longint;
s1,s2:ansistring;
begin
l:=length(s);
if l=0 then exit(1);
if l=1 then
begin
case s[1] of
'(':exit(1);
')':exit(1);
'+':begin if z=1 then exit(3) else exit(1); end;
'*':begin if z=0 then exit(3) else exit(1); end;
end;
end;
k:=0;
pd:=0;
if s[1]='(' then begin try:=try(copy(s,2,length(s)-2),z);exit;end;
for i:=l downto 1 do
begin
if s[i]=')' then inc(k) else if s[i]='(' then dec(k);
if k=0 then
begin
if s[i]='+' then begin pd:=1;j:=i;break;end;
end;
end;
if pd=0 then
begin
k:=0;
for i:=l downto 1 do
begin if s[i]=')' then inc(k) else if s[i]='(' then dec(k);
if k=0 then
begin
if s[i]='*' then begin pd:=2;j:=i;break;end;
end; end;
end;
s1:=copy(s,1,j-1);
s2:=copy(s,j+1,l-j);
if pd=1 then
begin
if z=0 then
begin
ans1:=try(s1,0);
ans2:=try(s2,0);
try:=ans1*ans2 mod 10007;
exit;
end;
if z=1 then
begin
ans1:=try(s1,1);
ans2:=try(s2,0);
try:=ans1*ans2 mod 10007;
ans1:=try(s1,0);
ans2:=try(s2,1);
try:=(try+ans1*ans2) mod 10007;
ans1:=try(s1,1);
ans2:=try(s2,1);
try:=(try+ans1*ans2) mod 10007;
exit;
end;
end;
if pd=2 then
begin
if z=1 then
begin
ans1:=try(s1,1);
ans2:=try(s2,1);
try:=ans1*ans2 mod 10007;
exit;
end;
if z=0 then
begin
ans1:=try(s1,1);
ans2:=try(s2,0);
try:=ans1*ans2 mod 10007;
ans1:=try(s1,0);
ans2:=try(s2,1);
try:=(try+ans1*ans2) mod 10007;
ans1:=try(s1,0);
ans2:=try(s2,0);
try:=(try+ans1*ans2) mod 10007;
exit;
end;
end;
end;
begin
readln(s);
writeln(try(s,0));
end.