#include <stdio.h>
#include <stdlib.h>

int top = 0;
int S[100];
void push( int);
int pop(void);

int main()
{

  
  char C[7];
  int a, b, del;
    
  while((scanf("%s",C)) != EOF ){      
    
    if(C[0] == '+'){
      
      a = pop();      
      b = pop();      
      push(a+b);
    }
    else if(C[0] == '-'){
     
      a = pop();
      b = pop();
      push(b-a);
    }
    else if(C[0] == '*'){
      
      a = pop();
      b = pop();
      push(a*b);
    }
    else{
      push(atoi(C));
    }
  }
    
  printf("%d\n",S[top]);
    
  return 0;
    
}
   


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

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