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


int main(){

  int stac[101];
  char r[7];
  int top=0;
  int log;
  int i;

  for(i=0;i<101;i++)stac[i]=0;
  while(1){
    
    if(scanf("%s",&r[0])==EOF)break;
    
    if(r[0]=='+'){
      stac[top-1]=stac[top-1]+stac[top];
      stac[top]=0;
      top--;
    }
    else if(r[0]=='*'){
      stac[top-1]=stac[top]*stac[top-1];
      stac[top]=0;
      top--;
    }
    else if(r[0]=='-'){
      stac[top-1]=stac[top-1]-stac[top];
      stac[top]=0;
      top--;
      
    }
    else{
      log=strlen(r);
      top++;
      for(i=0;i<log;i++){
	stac[top]*=10;
	stac[top]+=r[i]-'0';
      }
    }
  }
  printf("%d\n",stac[top]);
  return 0;
}



      

