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

void push(int);
int pop(void);
int isEmpty(int);
int isFull(void);

int top=0;
int a[100];

int main(){
  
  int x,data[2];
  char s[100];

  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'|| s[0]=='-'||s[0]=='*'){
       data[0]=pop();
       data[1]=pop();
    }
     if(s[0]=='+'){
       push(data[1]+data[0]);

    }else if(s[0]=='-'){
       push(data[1]-data[0]);
  
    }else if(s[0]=='*'){
       push(data[1]*data[0]);

    }else {
	 x = atoi(s);
         push(x);
      
     }
    } 
   printf("\n%d\n",a[1]);
  return 0;
}

int isEmpty(int top){
   if(top==0) return top;
   else return 1;
  }

int isFull(void){
  if(top>=99)return 0;
  else return 1;
 }

void push(int x){
  if (isFull()==0) fprintf(stderr,"オーバーフロー\n");
  else top++;
  a[top]=x;
}

int pop(void){
  if (isFull()==0) fprintf(stderr,"オーバーフロー\n");
  else top--;
  return a[top+1];
}
 