#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

int main(void){
  int x[N],i;
  char nyan[N];
  i=0;
  while(scanf("%s",nyan)!=EOF){
    if(nyan[0]=='+'){
      x[i-2] = x[i-1]+x[i-2];
      i--;
    }
    else if(nyan[0]=='-'){
      x[i-2] = x[i-2]-x[i-1];
      i--;
    }
    else if(nyan[0]=='*'){
      x[i-2] = x[i-1]*x[i-2];
      i--;
    }
    else {
      x[i] = atoi(nyan);
      i++;
    }
  }
  printf("%d",x[i-1]);


  
  return 0;
  
}