#include <stdio.h>
#include <stdlib.h>

int sp,A[1000];
void sou (int x);
int re();
int main()
{
int i,j;
char hi[100];
sp=0;

while(scanf ("%s",hi)!=EOF){
if (hi[0]=='+'){
i=re();
j=re();
sou(i+j);
}else if (hi[0]=='-'){
j=re();
i=re();
sou(i-j);
}else if (hi[0]=='*'){
i=re();
j=re();
sou(i*j);
}else {
sou(atoi(hi));
}
}
printf ("%d\n",re());
      
return 0;
}
void sou (int x){
A[++sp]=x;
}
int re() {
sp--;
return A[sp+1];
}
    

