#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void push(int);
int pop();
int isEmpty();
int isFull();
int initialize();
int top,MAX=100,S[100];

int main(){
  char s[100];
  int i=1;
  int a,b;
  int top=0;
  int x;
  while(scanf("%s",&s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(b+a);
    }
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(b*a);
    }
    else {
    x = atoi(s);
    push(x);
    }
  }
  printf("%d\n",pop());
  return 0;
}
/*int initialize(){                                                             
  top=0;                                                                        
}                                                                               
int isEmpty(){                                                                  
  return top==0;                                                                
}                                                                               
int isFull(){                                                                   
  return top>=MAX-1;                                                            
}                                                                               
*/
void push(int x){
  //if(isFull())exit(2);                                                        
  top++;
  S[top]=x;
}
int pop(){
  //if(isEmpty())exit(2);                                                       
  top--;
  return S[top+1];
}


