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

int main(){
  int i = 0,buf1,buf2;
  int x[100];
  char s[100];
  
  while( scanf("%s", s) != EOF){
    if ( s[0] == '+' ){
      i--;
      buf1 = x[i+1];
      buf2 = x[i];
      x[i] = buf1 + buf2;
    } 
    else if ( s[0] == '-' ){
      i--;
      buf1 = x[i];
      buf2 = x[i+1];
      x[i] = buf1 - buf2;
    } 
    else if ( s[0] == '*' ){
      i--;
      buf1 = x[i+1];
      buf2 = x[i];
      x[i] = buf1 * buf2;
    } 
    else {
      i++;
      x[i] = atoi(s);
    }
  }
  printf("%d\n",x[i]);
  return 0;
}