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

int top = 0;
#define N 100
//void judge(void);

int main(){

  int n[N];
  char s[N];

  while(scanf("%s",s) != EOF){

    if(s[0] == '+'){
      n[top - 1] += n[top];
      top--;
      //judge();
    }
    else if(s[0] == '-'){
      n[top - 1] -= n[top];
      top--;
      //judge();
    }
    else if(s[0] == '*'){
      n[top - 1] *= n[top];
      top--;
      //judge();
    }
    else {
      n[++top] = atoi(s);
      //judge();
    }

  }
  printf("%d\n", n[top]);

  return 0;
}

/*void judge() {
  if(top == -1) {
    printf("Stack is empty\n");
    exit(1);
  }
  else if(top == 100) {
    printf("Stack is overflow\n");
    exit(2);
  }
}*/

