#include <stdio.h>
#include <stdlib.h>
#include <sysexits.h>
#define N 100
int top=1;
int s[N];
int pop();
void push(int x);
int isempty();
int isfull();

int main(void){

  int ans=0,i,x1,x2;
  char x[8];

  while((scanf("%s",&x))!=EOF){

      if(x[0]=='+'){
        x1=pop();
        x2=pop();
        push(x1+x2);
      }

      else if(x[0]=='-'){
        x2=pop();
        x1=pop();
        push(x1-x2);
      }

      else if(x[0]=='*'){
        x1=pop();
        x2=pop();
        push(x1*x2);
      }

      else if(x[0]=='/'){
        x1=pop();
        x2=pop();
        push(x1/x2);
      }
    else{
      //printf("ok%d\n",top );
      push(atoi(x));
    }
  }

  ans=pop();
  printf("%d\n",ans);
  return 0;

}

void push(int x){
    /*if(isfull()==1){
      printf("error(full)");
      exit(1);
    }*/
    top++;
    s[top]=x;
}

int  pop(){
  /*if(isempty()==1){
    printf("error(empty)\n");
    exit(1);
  }*/
  top--;
  return s[top+1];
}

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

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

