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

int main(void){
  char s[500];
  int i, flag = 0, num[100], top=0, m=0, a, b, ans;
  fgets(s, 500, stdin);
  for(i=0;i<strlen(s);i++){
    if('0' <= s[i] && s[i] <= '9'){
      m = m*10 + s[i]-'0';
      flag = 1;
    }
    else if(s[i] == ' '){
      if(flag == 1){
      num[top] = m;
      top++;
      m = 0;
      flag = 0;}
    }
    else if(s[i] == '\n'){}
    else{
      a = num[top-2]; b = num[top-1];
      //printf("%d, %d, %d\n", a, b, top);
      top-=2;
      if(s[i]=='+') num[top] = a+b;
      else if(s[i] == '-') num[top] = a-b;
      else if(s[i] == '*') num[top] = a*b;
      top++;
      flag = 0;
    }
    //printf("%c\n",s[i]);
  }
  printf("%d\n", num[0]);
  return 0;
}
