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

int main(){

  char A[N];
  int B[N],i=0;

  while(scanf("%s",A)!=EOF){
    if(A[0]=='+'){
      B[i-2]=B[i-2]+B[i-1];
      i--;
    }
    else if(A[0]=='-'){
      B[i-2]=B[i-2]-B[i-1];
      i--;
    }
    else if(A[0]=='*'){
      B[i-2]=B[i-2]*B[i-1];
      i--;
    }
    else{
      B[i]=atoi(A);
      i++;
    }
  }
  printf("%d\n",B[0]);
  return 0;
}

