#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 200
int isEmpty(int);
int main()
{
  int i=0, j, n=0, top=0, S[N];
  char c[N];
  for(i = 1 ; i < N ; i++)
    {
      if(scanf("%s",c)==EOF) break;

      else if(isEmpty(i)==1){     
      if(!strcmp(c,"+")){
	  S[i-2]=S[i-1] + S[i-2];
	i = i - 2;
      }else if(!strcmp(c, "-")){
	  S[i-2] = S[i-2] - S[i-1];
	  i = i - 2;
      }else if(!strcmp(c, "*")){
	  S[i-2] = S[i-2] * S[i-1];
	  i = i - 2;
	}
	else {
	  S[i] = atoi(c);
	}
      }
      else if(isEmpty(i-2)==0) break;
    }
  printf("%d\n",S[1]);
  return 0;
}

int isEmpty(int x){

  if(x == 0) return 0;
  else return 1;
}