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

#define N 200
#define MAX 1000000

int main(){
  int x, y;
  int tail=0, times=0;
  int compute[N];
  char symbol[MAX];
  

  while(scanf("%s", symbol)!=EOF){
    
    if(symbol[0]=='+'){
      x=compute[--tail];
      y=compute[--tail];
      compute[tail++]=y+x;
    }
    else if(symbol[0]=='-'){
      x=compute[--tail];
      y=compute[--tail];
      compute[tail++]=y-x;
    }
    else if(symbol[0]=='*'){
      x=compute[--tail];
      y=compute[--tail];
      compute[tail++]=x*y;
    }
    else {
      x=atoi(symbol);
      if(x==0 && symbol[0]!='0') exit(1);
      compute[tail++]=x;
    }

  }

  printf("%d\n", compute[tail-1]);

  return 0;
}