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

int main(){

  int x = 0, y = 0, top = 0;
  char c[100];
  int s[100];

  while(scanf("%s", c) != EOF){
    if(c[0] == '+'){
      x = s[top-2];
      y = s[top-1];
      s[top-2] = x+y;
      top--;
    }else if(c[0] == '-'){
      x = s[top-2];
      y = s[top-1];
      s[top-2] = x-y;
      top--;
    }else if(c[0] == '*'){
      x = s[top-2];
      y = s[top-1];
      s[top-2] = x*y;
      top--;
    }else{
      s[top] = atoi(c);
      top++;
    }
  }
  printf("%d\n", s[top-1]);

  return 0;
}
    

