#include<stdio.h>
#include<stdlib.h>
#include<string.h>
# define N 1000000
int main(){
  int top = 1;
  int y, z, x;
  char s[100];
  int stack[N];
  
  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){
      top = top - 1;
      y = stack[top + 1];
      top = top - 1;
      z = stack[top + 1];
      top++;
      stack[top] = z + y ;
     
    } else if ( s[0] == '-' ){
      top = top - 1;
      y = stack[top + 1];
      top = top - 1;
      z = stack[top + 1];
      top++;
      stack[top] = z - y;
    } else if ( s[0] == '*' ){
      top = top - 1;
      y = stack[top + 1];
      top = top - 1;
      z = stack[top + 1];
      top++;
      stack[top] = z * y;
    } else {
      x = atoi(s);
      top++;
      stack[top] = x;
    }
  }

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