
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define E 99
void push(int);
int pop(void);
//int isEmpty(void);
//int isFull(void);


int top=0;
int s[N];

int main(){
  int n,n1,n2;
  char *c;

  while(1){
    scanf("%s",c);
    if(atoi(c)!=0) push(atoi(c));
    else{
      n2=pop();
      n1=pop();
      if(*c=='+')push(n1+n2);
      if(*c=='-')push(n1-n2);
      if(*c=='*')push(n1*n2);
    } 
    if(getchar() == '\n') break;
  }
  
  printf("%d\n",pop());
  
  return 0;
}

void push(x){
  //if(isFull()==-1)return;
  top++;
  s[top]=x;
  return;
}

int pop(){
  //if(isEmpty()==-1) return -1;
  top--;
  return s[top+1];
}
/*
int isEmpty(void){
  if(top==0)return -1;
  return 0;
}

int isFull(void){
  if(top>N) return -1;
  return 0;
}
*/