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

#define STACK_SIZE 100
void push(int );
int pop(void );

int stack[STACK_SIZE];
int top = 0;

int main(){
  int x,y,t;
  char s[100];

  while( scanf("%s", s) != EOF ){
    if ( s[0] == '+' ){
      x = pop( );
      y = pop( );
      push(x + y);

    } else if ( s[0] == '-' ){
      x = pop( );
      y = pop( );
      push(y - x);

    } else if ( s[0] == '*' ){
      x = pop( );
      y = pop( );
      push(x * y);
       
    } else {
      t = atoi(s);
      push(t);
    }
  }
  printf("%d\n",pop()); 
  
  return 0;
}

int pop( ){
  if(top <= 0){
    top--;
    return 0;
  }
  else {
    top--;
    return stack[top + 1]; 
  }
}
 
void push(int p){
  stack[++top] = p;
}
 


 



 

