#include <stdio.h>
#include <ctype.h>

int stack[100] = {};
int stackPointer = -1;

void push(int);
void add();
void subtract();
void multiply();
void printAnswer();

int main(void)
{
  int i;
  char current;
  for (i = 0; i < 101; i++)
    {
      scanf("%c", &current);
      switch (current)
	{
	case '+':
	  add();
	  break;
	case '-':
	  subtract();
	  break;
	case '*':
	  multiply();
	}
      if (isdigit(current))
	push(current - '0');
    }
  printf("%d\n", stack[stackPointer]);
  return 0;
}

void push(int input)
{
  stack[++stackPointer] = input;
}

void add()
{
  int addition = stack[stackPointer] + stack[stackPointer-1];
  stack[stackPointer] = 0;
  stack[--stackPointer] = addition;
}

void subtract()
{
  int subtraction = stack[stackPointer-1] - stack[stackPointer];
  stack[stackPointer] = 0;
  stack[--stackPointer] = subtraction;
}

void multiply()
{
  int multiplication = stack[stackPointer] * stack[stackPointer-1];
  stack[stackPointer] = 0;
  stack[--stackPointer] = multiplication;
}

