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

#define N 100

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

int s_sub[N];
int top = 0;
  
int main(){
  
  int fact1,fact2;
  char S[N];
  
  while(scanf("%s",S) != EOF){
    if(S[0] == '+'){
      fact1 = pop();
      fact2 = pop();
      push(fact1 + fact2);
    }else if(S[0] == '-'){
      fact2 = pop();
      fact1 = pop();
      push(fact1 - fact2);
    }else if(S[0] == '*'){
      fact1 = pop();
      fact2 = pop();
      push(fact1 * fact2);
    }else push(atoi(S));
  }
  printf("%d\n",pop());
  return 0;
}

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

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


