#include <stdio.h>
#include <stdlib.h>
#define MAX 199
void initialize(void);
int isEmpty(void);
int isFull(void);
void push(int x);
int pop(void);
int top;
int S[MAX];
int main(){
  int ans=0;
  char x;
  initialize();
  while(1){
    if(scanf(" %c",&x)!=1) break;
    if(x>='0' && x<='9'){
      push((int)x);
      //printf("%c\n",x);
  }
    
    else if ( x == '+' ){
      ans=pop()+pop();
    } else if ( x == '-' ){
      ans=pop()-pop();
    } else if( x == '*' ){
      ans=pop()*pop();
    }
  }
  printf("%d\n",ans);
  return 0;
}
void initialize(void){
  top=0;
}

int isEmpty(void){
  if(top==0) return 1;
  else return 0;
}
int isFull(void){
  if(top>=MAX-1) return 1;
  return 0;
}
void push(int x){
  
  if(isFull()==1){
    fprintf(stderr,"??¨??????????????????????????????)\n");
    exit(1);
  }
  top++;
  S[top]=x;
}
int pop(void){
  
  if(isEmpty()==1){
    fprintf(stderr,"??¨???????????¢?????????????????????\n");
    exit(1);
    return 0;
  }
  top--;
  return S[top+1];
}