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

int stack[100];;
int n=0;

int main(void){
  int x;
  char s[100];
  int count=0;
  int i,n;
  int j=0;

  while( scanf("%s", s) != EOF ){
    
    for(i=0;s[i]!='\0';i++){
      
      if ( s[i] == '+' ){
	n=count-2;
	stack[n++] = stack[(count-2)] + stack[count-1];
	count=n;
	
      } else if ( s[i] == '-' ){
	n=count-2;
	stack[n++] = stack[(count-2)] - stack[count-1];
	count=n;
	
      } else if ( s[i] == '*' ){
	stack[j] = stack[j] * stack[j+1];
	
      } else {
	x = atoi(s);
	stack[count++]=x;
      }
    }
  }
  printf("%d\n",stack[0]);

  return 0;
}