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

int top, stack[1000];

void push(int c){

  stack[++top]=c;

}

int pop(){

  top--;

  return stack[top+1];

}

int main(){

  int x,first,second;
  char s[100];
  top=0;
  
  while(scanf("%s",s)!=EOF){
    
    if(s[0]=='+'){
      
      second=pop();
      
      first=pop();
      
      push(first+second);

    }
    else if(s[0]=='-'){

      second=pop();
      
      first=pop();
      
      push(first-second);

    }
    else if(s[0]=='*'){

      second=pop();
      
      first=pop();
      
      push(first*second);

    }
    else{
      
      push(atoi(s));

    }
  }


  printf("%d\n",pop());

  return 0;
}

