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

void push(int);
int pop();

int Stack[199];
int i = 0;

int main()
{
  int num1,num2,num;
  char c[199];
  while(scanf("%s",c) != EOF){
    if((c[0] >= '0') && (c[0] <= '9')){
      push(atoi(c));
    }
    else if(c[0] == '*'){
      num1 = pop();
      num2 = pop();
      num = num2*num1;
      push(num);
    }
    else if(c[0] == '+'){
      num1 = pop();
      num2 = pop();
      num = num2+num1;
      push(num);
    }
    else if(c[0] == '-'){
      num1 = pop();
      num2 = pop();
      num = num2-num1;
      push(num);
    }
  }
  printf("%d\n",num);
  return 0;
}

void push(int num){
  Stack[i] = num;
  i++;
}

int pop(){
  int num;
  i--;
  num = Stack[i];
  return num;
}

