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

#define N 101

int top,S[N];

int pop(){

  if(top == 0){
    fprintf(stderr,"アンダーフロー\n");
    exit(2);
  }

  return S[top--];

}

void push(int x){

  if(top == 100){
    fprintf(stderr,"オーバーフロー\n");
    exit(1);
  }

  S[++top] = x;

}


int main(){

  int n,a,b,status;

  char A[1000000];

  S[top] = NULL;

  while((status = scanf("%s",&A)) != EOF){
    
    if(A[0] == 42 || A[0] == 43 || A[0] == 45){
      
      switch(A[0]){
	
      case 42:
	b = pop();
	a = pop();
	push(a * b);
	break;

      case 43:
	b = pop();
	a = pop();
	push(a + b);
	break;

      case 45:
	b = pop();
	a = pop();
	push(a - b);
	break;
	
      }
      
    }
    
    else{
      push(atoi(A));
    }
    
  }

  printf("%d\n",S[top]);

  return 0;
}



