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

int main(){
  int top,operand[101],v;
  char s[200];

  top = 0;
  
  while(scanf("%s",s) != EOF){
    
    if(top > 101)break;
    
    if(s[0] == '+'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v + operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(1);
      
    } else if(s[0] == '-'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v - operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(2);
      
    } else if(s[0] == '*'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v * operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(3);
        
    } else if(s[0] == '/'){
      if(top < 2)continue;
      else if(top >= 2){
        v = operand[top-1];
        operand[top-1] = v / operand[top];
        top--;
      }
      if(operand[top] < -1000000000 || 1000000000 < operand[top] )exit(4);
    } else {
      top++;
      operand[top] = atoi(s);
      if(operand[top] > 1000000)exit(5);
    }
  }
  printf("%d\n",operand[top]);
       
  return 0;
}

