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

typedef struct cell{
 int num;
 struct cell* next;
}cell;


/*-----------------push------------*/
cell* push(cell *root,int x){

cell *new;
new=(cell*)malloc(sizeof(cell));
new->next=NULL;
new->num=x;

if(root==NULL){root=new;}
else{new->next=root;root=new;}

return root;
}
/*----------------------------------*/



cell* pop(cell *root,int *x){

*x=root->num;
root=root->next;
return root;
}



int main(){
char temp[11];
cell *root=NULL;
int a,b;

while(scanf("%s",temp)!=EOF){
 if(temp[0]=='+'){root=pop(root,&a);root=pop(root,&b);root=push(root,a+b);}
 else if(temp[0]=='-'){root=pop(root,&a);root=pop(root,&b);root=push(root,a-b);}
 else if(temp[0]=='*'){root=pop(root,&a);root=pop(root,&b);root=push(root,a*b);}
 else{root=push(root,atoi(temp));}

}

 printf("%d\n",root->num);


return 0;
}
