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

int main(){
  int x, a, b;
  char s[100];

  int stack[1000];
  int current = 0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      current--;
      a = stack[current--];
      b = stack[current];
      stack[current++] = a + b;
    } else if ( s[0] == '-' ){
      current--;
      a = stack[current--];
      b = stack[current];
      stack[current++] = a - b;
    } else if ( s[0] == '*' ){
      current--;
      a = stack[current--];
      b = stack[current];
      stack[current++] = a * b;
    } else {
      x = atoi(s);
      stack[current++] = x;
    }
  }
  current--;
  printf("%d\n", stack[current]);

  return 0;
}

