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

int Stack[100],top=0;

void push(int);
int pop(void);

void push(int n)
{
  Stack[++top] = n;
}

int pop()
{
  top--;
  return Stack[top+1];
}

int main()
{
  int x,y;
  char word[100];
  
  while(scanf("%s",word) != EOF) {
    if(word[0] == '+') {
      x = pop();
      y = pop();
      push(x+y);
    }else if(word[0] == '-'){
      y = pop();
      x = pop();
      push(x-y);
    }else if(word[0] == '*'){
      x = pop();
      y = pop();
      push(x*y);
    }else{
      push(atoi(word));
    }
  }

  printf("%d\n",pop());

  return 0;
  
}
      
      
      

