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

int top=0,Stack[100];

void push(int);
int pop();

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

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

  printf("%d\n",pop());
  
  return 0;
}

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

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

