#include <stdio.h>
#include <ctype.h>

#define STACK 10


int main(void)
{
  int stack[STACK]; 
  int stack_n=0;  
  int sum;
  int digit_f=0; 
  int k;  
  char ch;  
  
  while( (ch = getchar()) != '\n' ) { 
   
    if( isdigit(ch) ) { 
      if( digit_f ) { 
        stack[stack_n] = stack[stack_n] * 10 + (ch - '0'); 
      } else {
        stack[stack_n] = (ch - '0');
        digit_f++;
      }
    }
    if( isspace(ch) ) { 
      if( digit_f ) {
        stack_n++;
        digit_f = 0;
      }
    }
    if( ch == '+' ) { 
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] += stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '-' ) { 
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] -= stack[stack_n];
      stack[stack_n] = 0;
    }
    if( ch == '*' ) {
      if( stack_n > 1 ) {
        stack_n--;
      }
      stack[stack_n-1] *= stack[stack_n];
      stack[stack_n] = 0;
    }
  }
  printf("%d\n",stack[0]);
  return 0;
}