/*s1190073  Rina Sato
 File name: prog3a.c
 This is a program that finds an answer of reverse polish notation using a stack.*/

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

void push(int);
int pop(void);

int S[101];
int j=0;

int main(void){
  char s[400];
  int x,m,n,i=0,count=0;
  
  while(1){  /*enter characters and recognize as a string*/
    scanf("%c",&s[i]);
    if(s[i] == '\n'){
      s[i]='\0';
      break;
    }    
    i++;
  }

  for(i = 0 ; i < strlen(s) ; i++){

    for(count=i ; s[count] != ' ' ; count++);  /*count a number of entering until                                                                          space*/
    
    if(s[i] >= '0' && '9' >= s[i]){ 
      x = atoi(s+i);  /*transform characters'0'~'9' into numerals*/
      i = count; 
      push(x);  
    }
    else if(s[i] == '+'){ /*add numbers picked up*/
      m = pop(); 
      n = pop(); 
      push(n+m);
      
    }
    else if(s[i] == '-'){ /*subtract numbers picked up*/
      m = pop();
      n = pop(); 
      push(n-m);
      
    }
    else if(s[i] == '*'){ /*do multiplication numbers picked up*/
      m = pop();
      n = pop(); 
      push(n*m);
      
    }  
  }
  printf("%d\n",S[0]);
  return 0;
}

void push(int x)
{ /*enter numbers*/
  S[j++] = x; 
}

int pop(void)
{ /*pick up numbers*/
  return S[--j];
}