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

int top=0;
int stack[100];
int pop(void);

int main(){
  int y,a;
  char x,s[100];

  while(1){
    scanf("%s",s);

    if(s[0] =='+'){
      a = pop() + pop();
      stack[top] = a;
      top++;
      if(getchar() == '\n')break;
    }
    else if(s[0] == '-'){
      a = pop() - pop();//aaaaaaaaaa
      stack[top] = a * -1;
      top++;
      if(getchar() == '\n')break;
    }
    else if(s[0] == '*'){
      a = pop() * pop();
      stack[top] = a;
      top++;
      if(getchar() == '\n')break;
    }
    else{
      a = atoi(s);
      stack[top] = a;
      top++;
    }
  }

  printf("%d\n",stack[0]);

  return 0;
}

int pop(void){
  top --;
  return stack[top];
}

