#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 1000

int top,let[N];

 void push(int);
 int pop();

int main(){
   char str[100];
   int n1,n2,x;
   top = 0;
 
   while(scanf("%s",str) != EOF){
     if(str[0]=='+'){
           n1 = pop();
           n2 = pop();
           push(n1+n2);
     }else if(str[0] =='-'){
           n1 = pop();
           n2 = pop();
           push(n2-n1);
     }else if(str[0] =='*'){
           n1 = pop();
           n2 = pop();
           push(n1*n2);
     }else{
       
      x = atoi(str);
      push(x);
     }

}

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

void push(int x){
  if(top == N-1){
    printf("Stack overflow\n");
    exit(2);
  }
    let[++top] = x;
}

int pop(){
  if(top == 0){
    printf("Stack is empty\n");
    exit(2);
  }
  top--;
  return let[top+1];

}



