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

int top = 0;
int test[101];

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

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

int main()
{
  char arr[100];
  int a, b;
  
  while(scanf("%s", arr) != EOF)
    {
      if(arr[0] == '+')
	{
	  push(pop()+pop());
	}
      else if(arr[0] == '-')
	{
	  a = pop();
	  b = pop();
	  push(b-a);
	}
      else if(arr[0] == '*')
	{
	  push(pop()*pop());
	}
      else
	{
	  push(atoi(arr));
	}
    }
  printf("%d\n", pop());
}

