#include <stdio.h>
#include <stdlib.h>
#define MAX 200

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

int top=0;
int stack[MAX];

int main(){

  int a,b,x;
  char s[100];
  while(scanf("%s",s)!=EOF){
      if(s[0]=='+') {
	b=pop();
	a=pop();
	a+=b;
	push(a);
      }
      else if(s[0]=='-'){
	b=pop();
	a=pop();
	a-=b;
	push(a);
      }
      else if(s[0]=='*'){
	b=pop();
	a=pop();
	a*=b;
	push(a);
      }
      else {
	x=atoi(s);
	push(x);
      }
    
  }
  printf("%d\n",stack[top]);

  return 0;
}

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

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

