#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
  int data[100],top=0;
  char s[101];
  while(scanf("%s", s) != EOF){
    if ( s[0] == '+' ){
        top--;
        data[top-1]=data[top-1]+data[top];
    }
    else if ( s[0] == '-' ){
        top--;
        data[top-1]=data[top-1]-data[top];
    }
    else if ( s[0] == '*' ){
        top--;
        data[top-1]=data[top-1]*data[top];
    }else if ( s[0] == '/' ){
        top--;
        data[top-1]=data[top-1]/data[top];
    }
    else {
      data[top] = atoi(s);
      top++;
    } 
  }
  printf("%d\n",data[0]);
  
  return 0;
}
