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