#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
char str[2100003];
int opr[1000004], num[1000004], no, nn;
int get_qua(int l, int r) {
int ans = num[l];
for (int i = l + 1; i <= r; i++) {
(ans *= num[i]) %= 10000;
}
return ans;
}
int main() {
freopen("expr2013.in", "r", stdin);
freopen("expr2013.out", "w", stdout);
cin >> str;
opr[no++] = -1;
for (int i = 0; str[i]; i++) {
if (isdigit(str[i])) {
int ans = 0;
for (; isdigit(str[i]); i++)
ans = ans * 10 + str[i] - '0';
i--;
num[nn++] = ans;
}
if (str[i] == '+')
opr[no++] = nn - 1;
}
opr[no++] = nn - 1;
int ans = 0;
for (int i = 1; i < no; i++) {
(ans += get_qua(opr[i - 1] + 1, opr[i])) %= 10000;
}
printf("%d\n", ans);
}