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

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

int stack[100];
int top = 0;

int main(){
  int x,f1,f2;
  char s[100];
  
  stack[0] = 0;

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      f1 = pop();
      f2 = pop();
      push(f1+f2);
    } else if ( s[0] == '-' ){
      f1 = pop();
      f2 = pop();
      push(f2-f1);
    } else if ( s[0] == '*' ){
      f1 = pop();
      f2 = pop();
      push(f1*f2);
    } else {
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",pop());

  return 0;
}

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

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

