#include<bits/stdc++.h>
using namespace std;
long long num[220000000];//存数字
char eq[220000000];//存运算符号
long long cnt=1;//1.存数字读入的进度(如num[cnt]就是第cnt个被读入的数字)2.到最后起到一个一共有多少个数的作用
long long ans=0;//结果
int main(){
scanf("%lld", &num[cnt]);//读入No.1数
num[cnt]%=10000;//取模
while(cin>>eq[cnt]){//挨个挨个的读入运算符号
cin>>num[cnt++];//读入数字No.cnt
num[cnt]=num[cnt]%10000;//取模again
}
for(int i=cnt; i>=1; i--){//倒序遍历
if(eq[i]=='*'){//如果是乘法...
num[i]=num[i]*num[i+1];//赋个值
num[i]=num[i]%10000;//取模again&again...
num[i+1]=0;//此元素out!
}
}
for(int i=1; i<=cnt; i++){
ans=ans+num[i];
ans=ans%10000;//累计加和+取模again&again&again
}
printf("%lld\n", ans);//输出
}
//奥利给!!!