#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 100

int main(void){
  int i=0, ans=0, y;
  int num[N];
  char s[N];
  
  while(scanf("%s",s) != EOF){

    if(s[0] == '+'){
      ans = num[i-2] + num[i-1];
     num[i-2] = ans;
      i--;
    }

    else if(s[0] == '-'){
      ans = num[i-2] - num[i-1];
      num[i-2] = ans;
      i--;
    }

    else if(s[0] == '*'){
      ans = num[i-2] * num[i-1];
      num[i-2] = ans;
      i--;
    }

    else{
      y = atoi(s);
      num[i] = y;
      i++; 
    }
  
  }
  printf("%d\n", num[0]);
  return 0;
}