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



typedef int stack_data;
#define success 1
#define failure 0

typedef struct{
  int data_num;
  int stack_size;
  stack_data *data;
}stack;


stack *make_stack(int stack_size){
  stack *p;
  p=malloc(sizeof(stack));
  p->data=malloc(stack_size*sizeof(stack_data));
  p->stack_size=stack_size;
  p->data_num=0;
  return p;
}


int push(stack *S,stack_data a){
  if(S->data_num < S->stack_size){
    S->data[S->data_num]=a;
    S->data_num++;
    return success;
  }
  else return failure;
}

int pop(stack *S,stack_data *p){
   if(S->data_num>0){
     *p=S->data[S->data_num -1];
      S->data_num--;
      return success;
   }
   else return failure;
}


int main(){
  char c[8];
  int *x,*y,z;
  x=malloc(sizeof(int));
  y=malloc(sizeof(int));
  stack *S;
  S=make_stack(101);
  while(scanf("%8s",c)!=EOF){
    if('+'==c[0]){
      pop(S,x);
      pop(S,y);
      z=x[0]+y[0];
      push(S,z);
    }
    else if('-'==c[0]){
      pop(S,x);
      pop(S,y);
      z=-x[0]+y[0];
      push(S,z);
    }
    else if('*'==c[0]){
      pop(S,x);
      pop(S,y);
      z=x[0]*y[0];
      push(S,z);
    }
    else{
      z=atoi(c);
      push(S,z);
    }
  }
  printf("%d\n",S->data[0]);
  return 0;
}