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

void push(int);
int pop(void);

int main(){
  int x,i=0,pp=0;
  char s[100];

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){

      push(pop() + pop());

    } else if ( s[0] == '-' ){

      pp = pop();
      push(pop() - pp);
      

    } else if ( s[0] == '*' ){

      push(pop() * pop());

    } else if(s[0] == ' '){
    
    }else {
      
      x = atoi(s);
      //x=x-48;

      //printf("*%d\n",x);/*test*/

      push(x);

    }
    i++;
  }


  printf("%d\n",(int)pop());

  return 0;
}


int now = 0;
int value[100];

/*     push    */
void push(int num)
{//printf("**%d\n",num);/*test*/
  if (now < 100){
    value[now] = num;
    now++;
    
  }
  else exit(8);
}

/*   pop   */
int pop(void)
{
	if (now > 0)
		return value[--now];
	else exit(8);
}