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

#define SDATAMAX 100

int top;
int stack[SDATAMAX];

void push(int);
int pop(void);

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

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      push(pop() + pop());
    } else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b - a);
    } else if ( s[0] == '*' ){
      push(pop() * pop());
    } else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void push(int x)
{
  top++;
  stack[top] = x;
}

int pop(void)
{
  top--;
  return stack[top + 1];
}
    

