#include<stdio.h>
#include<ctype.h>

void push(int);
int pop();

int top = 0; 
int S[1001];

int main(){

  char A[1000];
  int top, i, j;

  while(scanf("%s",A) != EOF){

    if(isdigit(A[top])){
      push(atoi(A[top]));
    }
    else{
      
      i = pop();
      j = pop(); 
 
      switch(A[top]){
	
      case '+':
	push( i + j);
	break;
      
      case '-':
	push( i - j);
	break;
  
      case '*':
	push( i * j);
	break;
      }
    }
  }

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

  return 0;
}

int pop(){
  top--;
  return S[top + 1];
}

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