#include <stdio.h>
#include <ctype.h>
#define STACK 100
int main(void)
{
  int stack[STACK];
  int stack_n; 
  int sum;
  int digit_f;
  int k;
  char ch;
  stack_n = 0;
  digit_f = 0;
  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;
    }
    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;
}