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

#define TRUE 1
#define FALSE 0
#define MAX 397

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

int top=0,S[100];

int main(){
  int x,i,x1,x2,count=0;
  char s[MAX];
  
   for( i = 0 ; i < MAX ; i++ )
     {
      scanf("%c",&s[i]);
      if(s[i] ==  '\n' ) break;
      count++;
     }
  
  for(i = 0 ; i <= count ; i++)
    {
      if(s[i] == ' ' || s[i] == '\n') continue; 
      else if ( s[i] == '+' )
	{
	  x = pop() + pop();
	  if(x < -1000000000 || x  > 1000000000 ) return 0;
	  push(x);
	}
      else if ( s[i] == '-' )
	{
	  x1 = pop();
	  x2 = pop();
	  x = x2 - x1;
	  if(x < -1000000000 || x  > 1000000000 ) return 0;
	  push(x);
	}
      else if ( s[i] == '*' )
	{
	  x = pop() * pop();
	  if(x < -1000000000 || x  > 1000000000 ) return 0;
	  push(x);
	}
      else
	{
	  if(i == 0 || s[i-1] ==  ' ')
	    {
	      x = atoi(&s[i]);
	      if(x < 0 || x > 1000000) return 0;
	      push(x);
	    }
	}
    }
  
  for(i = 1 ; i <=  top ; i++ )
    {
      printf("%d",S[i]);
    }

  printf("\n");
  
  return 0;
}

int isEmpty()
{
  if(top == 0) return TRUE;
  else return FALSE;
}

int isFull()
{
  if(top >= MAX-1) return TRUE;
  else return FALSE;
}

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

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

