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

struct node {
  int key;
  struct node *next;
};
typedef struct node * NodePointer;

void listinitialize(void);
void push(int);
int pop(void);
void print_stack(void);
int isempty(void);

NodePointer head, tail;

int main(){
  
  char s[1000];
  int temp1,temp2;
  int x;
  
  listinitialize(); 
  
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      temp1=pop();
      temp2=pop();
      push(temp1+temp2);
    }else if(s[0] == '-'){
      temp1=pop();
      temp2=pop();
      push(temp2-temp1);
    }else if(s[0] == '*'){
      temp1=pop();
      temp2=pop();
      push(temp1*temp2);
    }else{
      x=atoi(s);
      push(x);
    }
  }

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

void listinitialize(void){
  head = malloc(sizeof(struct node));
  tail = malloc(sizeof(struct node));

  head->next = tail;
  tail->next = tail;
}

void push(int key){
    NodePointer x;
  
  x = malloc(sizeof(struct node));
  x->key = key;

  x->next = head->next;
  head->next = x;  
}
int pop(){

  int x;
  NodePointer n;

  if(!isempty()){
    x=head->next->key;
    n=head->next;
    head->next = n->next;
    free(n);
  }else{
    printf("stack is empty\n");
    exit(1);
  }
  
  return x;
}
int isempty(){
  if(head->next == tail){
    return 1;
  }else{
    return 0;
  }
}
void print_stack(){
    NodePointer n;

  n = head->next;
  while (n != tail) {
    printf("%d ", n->key);
    n = n->next;
  }
  printf("\n");
}