#include<stdio.h>
#include<iostream>
#include<stack>
using namespace std;
int main()
{
stack<int> s;
int i=0;
int flag1,flag2;
int end=0;
int tmp;
char str[40];
while(1)
{
scanf("%c",&str[i]);
if(str[i]=='\n')
{
break;
}
if(str[i]>='0'&&str[i]<='9')
{
tmp=int(str[i])-48;
s.push(tmp);
}
if(str[i]=='+')
{
flag1=s.top();
s.pop();
flag2=s.top();
s.pop();
tmp=flag1+flag2;
s.push(tmp);
}
if(str[i]=='-')
{
flag1=s.top();
s.pop();
flag2=s.top();
s.pop();
tmp=flag2-flag1;
s.push(tmp);
}
if(str[i]=='/')
{
flag1=s.top();
s.pop();
flag2=s.top();
s.pop();
tmp=flag2/flag1;
s.push(tmp);
}
if(str[i]=='*')
{
flag1=s.top();
s.pop();
flag2=s.top();
s.pop();
tmp=flag1*flag2;
s.push(tmp);
}
i=i+1;
}
flag1=s.top();
end=flag1;
printf("%d\n",end);
return 0;
}