#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 100
void push(int);
int pop(void);
int top=0,S[SIZE];
int main(){
  int s,t,a,p;
  char x[SIZE];
  while((p=scanf("%s",x))!=EOF) {
    
if(x[0]=='+')  {
  s=pop();
  t=pop();
  push(s+t);
 }
     else if(x[0]=='-'){
       s=pop();
       t=pop();
       push(t-s);
     }
     else if(x[0]=='*'){
       s=pop();
       t=pop();
       push(s*t);
     }
     else push(atoi(x));
 
  }
  a=pop();
  printf("%d\n",a);

 return 0;
}

void push(int x){
  if(top==SIZE){
    printf("Stack is overflow\n");
    exit(2);
  }
   top++;
  S[top]=x;
 
  
}

int pop(void){
  if(top==0){
    printf("Stack is Empty\n");
    exit(2);
  }
  top--;
  return S[top+1];
}

