#include <stdio.h>
#include <stdlib.h>
#define MAX 100

int S[MAX];
int top;

void print_stack(void){
  
  int i;
  
  printf("in print_stack function\n");
  for(i=1;i<=top;i++)printf("top=%d => %d\n",i,S[i]);
  printf("\n");
}

int initialize();
int isEmpty();
int isFull();
void push(int);
int pop();

int main(){
  int x,sub;
  char s[1];

  int a,b;

  initialize();
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      //printf("== in if + ==\n");
      push(pop() + pop());
    }else if(s[0] == '-'){
      //printf("== in if - ==\n");
      sub = pop();
      push(pop() - sub);
    }else if(s[0] == '*'){
      //printf("== in if * ==\n");
      push(pop() * pop());
      //a = pop();
      //b = pop();
      //printf("before push -- 1:%d, 2:%d\n",a,b);
      //push(a*b);
      //a = pop();
      //b = pop();
      //printf("after  push -- 1:%d, 2:%d\n",a,b);
      
    }else{
      //printf("== in push value ==\n");
      x = atoi(s);
      push(x);
    }
  }
  printf("%d\n",S[top]);
  return 0;
}
int initialize(){
  top = 0;
}
int isEmpty(){
  return top == 0;
}
int isFull(){
  return top >= MAX - 1;
}
void push(x){

  //printf("x= %d\n",x);
  if(isFull());
  top++;
  //printf("in push:%3d ,%d\n",x,top);/*debug*/
  S[top] = x;
  //print_stack();
}
int pop(){
  
  if(isEmpty());
  top--;
  //printf("in pop :%3d ,%d\n",S[top+1],top+1);/*debug*/
  //print_stack();
  return S[top+1];
}