#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
void my_push(int);
int my_pop(void);
 
  int count=0;
  int stack[100];
 
int main(void){
 
  int x;
  int a,b;
  char s[100];
 
  while(1){
    if(scanf("%s", s) == EOF)
      break;
    
    if ( s[0] == '+' ){
      a = my_pop();
      b = my_pop();
      my_push(b + a);
    }
    else if ( s[0] == '-' ){
      a = my_pop();
      b = my_pop();
      my_push(b - a);
    }
    else if ( s[0] == '*' ){
      a = my_pop();
      b = my_pop();
      my_push(b * a);
    }
    else {
      x = atoi(s);
      my_push(x);
    }
  }
  printf("%d\n",stack[0]);
  return 0;
}

void my_push(int x){
  
  stack[count++] = x;  
}

int my_pop(void){
  
  return stack[--count];
}