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

#define Max 1000

int s[Max],top;


void push(int);
int pop(void);

int main(){
  char A[100];
  int i,x,first,second;
  

  while(scanf("%s",A)!=EOF){
    if(A[0]=='+'){
      first=pop();
      second=pop();
      push(first+second);
    }
    else if(A[0]=='-'){
      second=pop();
      first=pop();
      push(first-second);
    }
    else if(A[0]=='*'){
      first=pop();
      second=pop();
      push(first*second);
     
    }
    else{
      x=atoi(A);
      push(x);
    }
  }
  
  printf("%d\n",pop());
  
  
    
  
  return 0;
}



int pop(){
  top--;
  return s[top+1];
}

void push(int x){
  
  
  s[++top]=x;
}

  

  

