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

int top = 0,stack[100];
void push(int);
int pop(void);

int main(){
  int num1,num2;
  char s[100];

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

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

  return 0;
}

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

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

