#include <stdio.h>
#include <string.h>
int s[100000]={}, top=-1;
int push(int a)
{
top++;
s[top]=a;
}
void pop()
{
if(top!=-1)
{
top--;
}
}
int main()
{
char arr[1024]={};
gets(arr);
int p=0;
for(int i=0;i<=strlen(arr);i++)
{
if(arr[i]>='0' && arr[i]<='9')
{
p=p*10+arr[i]-'0';
}
else if(arr[i]==' ' && arr[i-1]>='0' && arr[i-1]<='9')
{
if(p!=0)
{
push(p);
p=0;
}
}
else if(arr[i]=='+')
{
int w;
w=s[top]+s[top-1];
pop();
pop();
push(w);
}
else if(arr[i]=='-')
{
int w;
w=s[top-1]-s[top];
pop();
pop();
push(w);
}
else if(arr[i]=='*')
{
int w;
w=s[top-1]*s[top];
pop();
pop();
push(w);
}
}
printf("%d",s[top]);
}



