#include <bits/stdc++.h>
using namespace std;
stack <int> s;//开栈
string st;//输入字符串
char c[100010];//存储stack中的数
int main () {
cin >> st;//输入
int l = st.length();//存储字符串长度
for (int i = 0; i < l; i ++ ) {
if (s.top() == '*') {
s.pop();
int x = s.top() - '0';
s.pop();
while (s.top() != '+') {
x = x * 10 + c[i] - '0';
s.pop();
}//判断是否为大于10的数
int y = x * (st[i] - '0');
s.push(y);
}//判断是否为乘法,如果是就相乘
else {
s.push(st[i]);
}//存储其余字符
}
int i = 1;//i为剩余长度
while (! s.empty()) {//把栈中所有字符存储到c数组中
c[i] = s.top();
i ++ ;
}
for (int j = i; j >= 1; j -- ) {
if (s.top() == '+') {
s.pop();
int x = s.top() - '0';
s.pop();
while (s.top() != '+') {
x = x * 10 + c[i] - '0';
s.pop();
}
int y = x + c[i] - '0';
s.push(y);//入栈
}//判断加法
else {
s.push(c[i]);
}
}
cout << s.top() % 10000;//输出
return 0;
}