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

int main(){
  int i = 0, tmp;
  char array[100];
  int stack[99];

  while(scanf("%s",array) != EOF){
    if ( array[0] == '+' ){
      tmp = 0;
      tmp += stack[i];
      stack[i] = 0;
      i -= 1;
      tmp += stack[i];
      
      stack[i] = tmp;
      
    }
    else if ( array[0] == '-' ){
      tmp = 0;
      tmp -= stack[i];
      stack[i] = 0;
      i -= 1;
      tmp += stack[i];
      
      stack[i] = tmp;
    }
    else if ( array[0] == '*' ){
      tmp = 1;
      tmp = tmp * stack[i];
      stack[i] = 0; 
      i -= 1;
      tmp = tmp * stack[i];

      stack[i] = tmp;
    }
    else {
      i++;
      stack[i] = atoi(array);
    }
  }

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

