#include <stdio.h>
#include<stdlib.h>
#define Max 100
int top = 0,S[Max];
int main(){
  int x;
  char c[Max];

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