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

#define size 1000

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

int stack[size];
int top = 0;

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

  while(scanf("%s",s) != EOF){
    /* if(s[0] =='F') break; */
    if(s[0] == '+'){
      
      a = pop();
      b = pop();

      /*printf("%d %d \n",a,b);*/
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else{
      x = atoi(s);
      push(x);
    }

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

  return 0;
}


void push(int x){
  if(top == size){
    exit(2);
      }
  top++;
  stack[top] = x;
}

int pop(void){
  if(top == 0){
    exit(3);
  }
  top--;
  return stack[top+1];
}
  
  
  

