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

void push(int);
int pop();

int top = 0; 
int S[101];

int main(){

  char A[100];
  int i, j;

  while(scanf("%s",A) != EOF){
    //printf("%d %d\n",top,A[top]);
    //fflush(stdout);
    if(isdigit(A[0])){
      push(atoi(A));
    }
    else{
      
      i = pop();
      j = pop(); 
 
      if(A[0] == '+')
	push( i + j);
      else if(A[0] =='-')
	push( j - i);
      else if (A[0] == '*')
	push (i * j);
      }
  }

  printf("%d\n",pop()  );

  return 0;
}

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

void push(int x){
  //printf("%d %d\n",top,S[top]);
  // fflush( stdout );
  S[++top] = x;
}