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

int top,stack[1000];

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

int main(){
 
  top = 0;
  int num1,num2;
  char n[100];

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

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

  return 0;
}

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

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

