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

typedef struct{
  int stk[100];
  int top;
}Stack;

Stack S;

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

int main(){
  char *str;
  int a,b;

  while(scanf("%s",str)!=EOF){
    if(atoi(str)!=0){
      push(atoi(str));
    }

    else{
      switch(str[0]){
      case '+':
	a = pop();
	b = pop();
	push(a+b);
	break;
	
      case '-':
	a = pop();
	b = pop();
	push(b-a);
	break;
	
      case '*':
	a = pop();
	b = pop();
	push(a*b);
	break;
	
      default:
	break;
      }
    }
  }

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

int isEmpty(){
  if(S.top == 0)
    return 1;
  else
    return 0;
}

void push(int x){
  S.stk[++S.top] = x;
}

int pop(){
  if(isEmpty()){
    fprintf(stderr,"underflow!!\n");
    exit(8);
  }

  else
    S.top--;
  
  return S.stk[S.top + 1];
}

