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

void push(int);
int pop(void);
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("%d\n",a[1]);
  return 0;
}


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

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

}

int pop(){
  /*
  if (isFull()==0){fprintf(stderr,"アンダーフロー\n");
  exit(2);}*/
   top--;
  return a[top+1];
}
 