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

int top=0,S[N];

void push(int x){
  if(top==N){
    printf("Stack overflow!\n");
    exit(2);
    }
   S[++top]=x;
}
int pop(void){
   if(top==0){
    printf("Stack is empty!\n");
    exit(3);
    }
   top--;
    return S[top+1];
}

int main(){
  int a,b;
  top=0;
  char s[100];

  while( scanf("%s", s) != EOF){
    if(s[0]=='+'){
      push(pop()+pop());
    }
    else if(s[0]=='-'){
      b=pop();
      a=pop();
      push(a-b);
    }
    else if(s[0]=='*'){
      push(pop()*pop());
    }
    else{
      push(atoi(s));
    }
  }

  printf("%d\n",pop());

  return 0;
}
