#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ADD -1
#define SUBTRACT -2
#define MULTIPLY -3

main(){

  int i, tmpInt, flag, j, exp, k;
  char tmp[8];
  long stack[199];
  char ret;

  i=0;
  while(1){

    j=0;
    flag=0;
    exp=0;
    while(1){
      scanf("%c",&tmp[j]);
      if(tmp[j] == '\n'){
	flag = 1;
	break;
      }else if(tmp[j] == ' '){
	break;
      }else if(tmp[j] == '+'){
	exp = ADD;
	break;
      }else if(tmp[j] == '-'){
	exp = SUBTRACT;
	break;
      }else if(tmp[j] == '*'){
	exp = MULTIPLY;
	break;
      }
      j++;
    }
    if(flag==1){
      break;
    }

    if(exp == ADD){
      stack[i-2] = stack[i-2] + stack[i-1];
      i-=1;
    }else if(exp == SUBTRACT){
      stack[i-2] = stack[i-2] - stack[i-1];
      i-=1;
    }else if(exp == MULTIPLY){
      stack[i-2] = stack[i-2] * stack[i-1];
      i-=1;
    }else if('1' <= tmp[0] && tmp[0] <= '9'){
      stack[i] = atoi(tmp);
      i++;
    }

  }

  printf("%ld\n",stack[0]);



return 0;

}