#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 200

int top,S[200];

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

int main()
{
  int x,data[2],sum;
  char s[100];

  while( scanf("%s",s) != EOF )
    {
      if ( s[0] == '+' )
      {
        data[0] = pop();
        data[1] = pop();
        push(data[0]+data[1]);

      }
      else if ( s[0] == '-' )
      {
	data[0] = pop();
	data[1] = pop();
	push(data[1]-data[0]);

      }
      else if ( s[0] == '*' )
      {
	data[0] = pop();
	data[1] = pop();
	push(data[1]*data[0]);
      }
      else
      {
        x = atoi(s);
	//	printf("%d\n",x);
	push(x);
	
      }
    }

  printf("%d\n",pop());
  return 0;
}

void push(int x)
{
  top++;
  S[top]=x;
}

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


