#include<stdio.h>
#include<stdlib.h>
int main(){
  int ope[100], top=0, flag=0;
  char c;
  while((c=getchar()) != '\n'){
    if(c == ' '){
      if(flag){
	top++;
	flag = 0;
      }
    }
    if(c == '+'){
      if(top > 1){
	top--;
      }
      ope[top-1] += ope[top];
      ope[top] = 0;
    }else if(c == '-'){
      if(top > 1){
	top--;
      }
      ope[top-1] -= ope[top];
      ope[top] = 0;
    }else if(c =='*'){
      if(top > 1){
	top--;
      }
      ope[top-1] *= ope[top];
      ope[top] = 0;
    }else if(c - '0' >= 0 && c - '0' <= 9){
      if( flag ) {
        ope[top] = ope[top] * 10 + (c - '0');
      } else {
        ope[top] = (c - '0');
        flag++;
      }
    }
  }

  printf("%d\n", ope[0]);
  return 0;
}

