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

int push(int *, int);
int pop(int *);
int isEmpty(void);
int isFull(void);

int top = 0;

int main(){
  int i, S[100];
  char x[100];

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

    if(x[0] == '+'){
      S[top - 1] += pop(S);
    }
    else if(x[0] == '-'){
      S[top - 1] -= pop(S);
    }
    else if(x[0] == '*'){
      S[top - 1] *= pop(S);
    }
    else{
      i = atoi(x);
      push(S, i);
    }
  }

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

  return 0;
}

int push(int *S, int x){
  /*if(isFull()){
    fprintf(stderr, "OverFlow\n");
    return 0;
    }*/
  top++;
  S[top] = x;
}

int pop(int *S){
  /*if(isEmpty()){
    fprintf(stderr, "UnderFlow\n");
    return 0;
    }*/
  top--;
  return S[top + 1];
}

int isFull(){
  if(top >= 99) return 1;
  else return 0;
}

int isEmpty(){
  if(top == 0) return 1;
  else return 0;
}