#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
main(){
  int x,sum=0,i,n,a,b;
  char s[110];
  int stack[110];
  int stack_top=0;
   
  while( scanf("%s",s) != EOF ){
    if( s[0] == '+' ){
      --stack_top;
      a = stack[stack_top];
      --stack_top;
      b = stack[stack_top];
      sum = a + b;
      stack[stack_top] = sum;
      stack_top++;
    }
    else if ( s[0] == '-' ){
      n =  stack[--stack_top];
      sum = stack[--stack_top] - n;
      stack[stack_top] = sum;
      stack_top++;
    }
    else if ( s[0] == '*' ){
      --stack_top;
      a = stack[stack_top];
      --stack_top;
      b = stack[stack_top];
      sum = a * b;
      stack[stack_top] = sum;
      stack_top++;
    }
    else {
      x = atoi(s);
      stack[stack_top] = x;
      stack_top++;
    }
  }
  for( i=0 ; i<stack_top ; i++) printf("%d\n",stack[i]);
  return 0;
}