#include <stack>
#include <cstdio>
#include <cctype>
using namespace std;
int pop(stack<int> &S) { int v=S.top(); S.pop(); return v; }
int main()
{
while(true)
{
stack<int> S;
for(int ch;(ch=getchar())!='\n';)
{
if(isdigit(ch)) S.push(ch-'0');
else if(ch=='+') S.top()+=pop(S);
else if(ch=='*') S.top()*=pop(S);
else if(ch=='-') S.top()-=pop(S);
else if(ch==EOF) return 0;
}
printf("%d\n",S.top());
}
}
I2luY2x1ZGUgPHN0YWNrPgojaW5jbHVkZSA8Y3N0ZGlvPgojaW5jbHVkZSA8Y2N0eXBlPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IHBvcChzdGFjazxpbnQ+ICZTKSB7IGludCB2PVMudG9wKCk7IFMucG9wKCk7IHJldHVybiB2OyB9CgppbnQgbWFpbigpCiAgewogICB3aGlsZSh0cnVlKQogICAgIHsKICAgICAgc3RhY2s8aW50PiBTOwogICAgICBmb3IoaW50IGNoOyhjaD1nZXRjaGFyKCkpIT0nXG4nOykKICAgICAgICB7CiAgICAgICAgIGlmKGlzZGlnaXQoY2gpKSBTLnB1c2goY2gtJzAnKTsKICAgICAgICAgZWxzZSBpZihjaD09JysnKSBTLnRvcCgpKz1wb3AoUyk7CiAgICAgICAgIGVsc2UgaWYoY2g9PScqJykgUy50b3AoKSo9cG9wKFMpOwogICAgICAgICBlbHNlIGlmKGNoPT0nLScpIFMudG9wKCktPXBvcChTKTsKICAgICAgICAgZWxzZSBpZihjaD09RU9GKSByZXR1cm4gMDsKICAgICAgICB9CiAgICAgIHByaW50ZigiJWRcbiIsUy50b3AoKSk7CiAgICAgfQogIH0K