#include <stdio.h>

void calc(char);
void push(int);
int pop(void);

int stack[100];

main(){

  int i, END_OF_INPUT;
  char str[9];

  stack[0]=0;

  while(1){

    for(END_OF_INPUT=0,i=0; ;i++){
      scanf("%c",&str[i]);
      if(str[i] == ' '){
	str[i]='\0';
	break;
      }
      if(str[i] == '\n'){
	str[i]='\0';
	END_OF_INPUT=1;
	break;
      }
    }

    if('0' <= str[0] && str[0] <= '9')
      push(atoi(str));
    else
      calc(str[0]);

    if(END_OF_INPUT) break;

  }

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

  return 0;

}

void calc(char exp){

  int op1, op2, ans;

  op2 = pop();
  op1 = pop();
  
  if(exp=='+')ans = op1 + op2;
  if(exp=='-')ans = op1 - op2;
  if(exp=='*')ans = op1 * op2;

  push(ans);

}

void push(int v){
  stack[++stack[0]] = v;
}

int pop(){
  return stack[stack[0]--];
}