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

int num[100],top=0;

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

int main(){
  int x,y;
  char S[100];

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

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

  int pop(){
    top--;
    
    return num[top];
  }
  
  

