#include<stdio.h>
#include<string.h>
#include<stdlib.h>
  int S[1000];
  int top;

void  push(int x){
  S[++top]=x;
}
int pop(){
 
  top--;
  
  return S[top+1];
}

int main (){
  int top=0;
  int i,j;
  char s[100];
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      i=pop();
      j=pop();
      push(i+j);
    }
    else if(s[0]=='-'){
      j=pop();
      i=pop();
      push(i-j);
      }
    else if(s[0]=='*'){
      i=pop();
      j=pop();
      push(i*j);
    }
    else {
      push(atoi(s));
    
    }
  }
  printf(" %d\n",pop());
}
    