#include <stdio.h>
#include <stdlib.h>
int main(){
  char s[16];
  int S[100],p=0;
  while (scanf("%s ",s)!=EOF){
    int a,b;
    if(*s>'/')
      S[p++]=atoi(s);
    else{
      a=S[--p];b=S[--p];
      if(*s=='*')S[p++]=b*a;
      else if(*s=='+')S[p++]=b+a;
      else if(*s=='-')S[p++]=b-a;
    }
  }
  printf("%d\n", S[--p]);
  return 0;
}