#include<stdio.h>
#include<stdlib.h>
#include<string.h>
  
int num,stack[200];
 
 
int pop(){
  num--;
  return stack[num+1];
}
 
 
void push(int n){
  stack[++num] = n;
}
 
 
int main(void){
  int a,b;
  num = 0;
  char c[100];
  while(scanf("%s",c)!=EOF){
    if( c[0] == '+' ){
      a = pop();
      b = pop();
      push( a + b );
    }
    else if( c[0] == '-' ){
      b = pop();
      a = pop();
      push( a - b);
    }
    else if( c[0] == '*' ){
      a = pop();
      b = pop();
      push( a * b );
    }
    else{
      push(atoi(c));  //文字列の数値をint型の数値に変換する
    }
  }
  printf("%d\n",pop());
  return 0;
}