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

#define N 100

int s[N];
int top;

void initialize(void);
int isFull(void);
int isEmpty(void);
void push(int);
int pop();

int main(){

  char sss[N];
  int num1,num2,x;

  initialize();

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

    if(sss[0] == '+'){
      num1 = pop();
      num2 = pop();
      push(num2 + num1);
    }

    else if(sss[0] == '-'){
      num1 = pop();
      num2 = pop();
      push(num2 - num1);
    }

    
    else if(sss[0] == '*'){
      num1 = pop();
      num2 = pop();
      push(num2 * num1);
    }

    else {
      x = atoi(sss);
      push(x);
    }
  }

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

  return 0;
}

void initialize(void)
{
  top = 0;
}

int isEmpty(void)
{
  if(top == 0) return 1;
  return 0;
}

int isFull(void){
  if(top >= N-1) return 1;
  return 0;
}

void push(int x)
{
  if(isFull()){
    exit(1);
  }
  top++;
  s[top] = x;
}

int pop(void){
  if(isEmpty()){
    exit(1);
  }
  top--;
  return s[top+1];
}

  