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


int main(){
  int i,top=0,stack[N],len;
  char n,r[7];

  for(i=0;i<N;i++)stack[i]=0;
  for(i=0;i<200;i++){
    if(EOF==scanf("%s",r))break;
    if(r[0]=='+'){
      stack[top-2]+=stack[top-1];
      top--;
      stack[top]=0;
    }
    else if(r[0]=='-'){
      stack[top-2]-=stack[top-1];
      top--;
      stack[top]=0;
    }
    else if(r[0]=='*'){
      stack[top-2]*=stack[top-1];
      top--;
      stack[top]=0;
    }
    else if(r[0]>='0' && r[0]<='9'){
      len=strlen(r);
      for(i=0;i<len;i++){
	stack[top]*=10;
	stack[top]+=r[i]-'0';
      }
      top++;
    }
  }
  printf("%d",stack[top-1]);
  printf("\n");
  return 0;
}

