#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 101

void syoki(void);
int karahan(void);
int manhan(void);
void ireru(int);
int dasu(void);
int top,stack[MAX];

int main()
{
  int x1,x2,x3=0;
  char charac[MAX];
  syoki();
  while(scanf("%s",charac)!=EOF)
    {
      if(charac[0]=='+')
	{
	  x1=dasu();
	  x2=dasu();
	  ireru(x1+x2);
	}
      else if(charac[0]=='-')
	{
	  x1=dasu();
	  x2=dasu();
	  ireru(x2-x1);
	}
      else if(charac[0]=='*')
	{
	  x1=dasu();
	  x2=dasu();
	  ireru(x1*x2);
	}
      else
	{
	  x3=atoi(charac);
	  ireru(x3);
	}
    }
  printf("%d\n",dasu());
  return 0;
}


void syoki()
{
  top = 0;
}
int karahan()
{
  if(top==0)
    {
      return 1;
    }
  else
    {
      return 0;
    }
}
int manhan()
{
  if(top>=MAX-1)
    {
      return 1;
    }
  else
    {
      return 0;
    }

}
void ireru(int x3)
{
  if (manhan()==1)
    {
      printf("エラー オーバーフロー\n");
    }
  else
    {
      top++;
      stack[top]=x3;
    }
}
int dasu(void)
{
  if (karahan()==1)
    {
      printf("エラー アンダーフロー\n");
    }
  else
    {
      top--;
      return stack[top+1];
    }
}



/*
 int x,i=0,stack[100],j=0,k,hokan,l=0;
  char c[100];

  while( scanf("%c", &c[i]) != '\n' )
    {
      if(c[i]!=' ')
	{
	  if ( c[i] == '+' )
	    {
	      hokan=0;
	      for(k=l;k<=j;k++)
		{
		  hokan=hokan+stack[k];
		}
	      stack[l]=hokan;
	      l++;
	    }
	  else if ( c[i] == '-' )
	    {
	      hokan=0;
      	      for(k=l;k<=j;k++)
		{
		  hokan=hokan-stack[k];
		}
	      stack[l]=hokan;
	      l++;

	    }
	  else if ( c[i] == '*' )
	    {
	      hokan=0;
      	      for(k=l;k<=j;k++)
		{
		  hokan=hokan*stack[k];
		}
	      stack[l]=hokan;
	      l++;
	    }
	  else
	    {
	      x = atoi(c[i]);
	      stack[j];
	      j++;
	    }
	}
      i++;
    }

  return 0;
*/
/*
 int x;
 char s[100];

 while( scanf("%c", &s[i]) != '\n' )
   {
     if ( s[0] == '+' )
       {

       }
     else if ( s[0] == '-' )
       {

       }
     else if ( s[0] == '*' )
       {

       }
     else
       {
	 x = atoi(s);

       }
   }

  return 0;
*/
/*
  int i=0,j,henka=0,suuti1=0,suuti2=0,stack[10],k=0;
  char c[100];

  while(1)
    {
      scanf("%c", &c[i]);
      if(c[i]=='\n')
	{
	  break;
	}
      i++;
    }
  i=0;
  while(1)
    {
      if(c[i]=='\n')
	{
	  break;
	}
      else if(c[i]!=' ')
f	{
	  if ( c[i] == '+' )
	    {
	      
		for(j=i-2;j<i;j++)
		{
		henka = (int)c[j];
		suuti=suuti+henka;   
		}
	      
	      suuti1=(int)c[i-4];
	      suuti2=(int)c[i-2];
	      
	      k=k-2;
	      stack[k]=stack[k]+stack[k+1];
	      //printf("%d\n",stack[k]);
	      //k++;
	      //c[i-4]=(char)henka;
	    }
	  else if ( c[i] == '-' )
	    {
	      
	      suuti1=(int)c[i-4];
	      suuti2=(int)c[i-2];
	      
	      k=k-2;
	      stack[k]=stack[k]-stack[k+1];
	      //k++;
	    }
	  else if ( c[i] == '*' )
	    {
	      
	      suuti1=(int)c[i-4];
	      suuti2=(int)c[i-2];
	      
	      k=k-2;
	      stack[k]=stack[k]*stack[k+1];
	      // c[i-4]=(char)henka;
	      //k++;
	    }
	  else
	    {
	      stack[k]=atoi(&c[i]);
	      //k++;
	    }
	  k++;
	}
      i++;
    }
  printf("%d\n",stack[0]);
  return 0;

 */
/*
  int i=0,x=0,p1,p2,m1,m2,k1,k2,j,flag=0;
  char c[MAX];
  while(1)
    {
      scanf("%c", &c[i]);
      if(c[i]=='\n')
	{
	  break;
	}
      i++;
    }
  i=0;
  syoki();
  while(1)
    {
      if(c[i]=='\n')
	{
	  break;
	}
      if(c[i]!=' ')
	{
	  if ( c[i] == '+' )
	    {
	      p1=dasu();
	      p2=dasu();
	      // printf("%d\n",p1+p2);
	      ireru(p1+p2);
	    }
	  else if ( c[i] == '-' )
	    {
	      m1=dasu();
	      m2=dasu();
	      // printf("%d\n",m2-m1);
	      ireru(m2-m1);
	    }
	  else if ( c[i] == '*' )
	    {
	      k1=dasu();
	      k2=dasu();
	      // printf("%d\n",k1*k2);
	      ireru(k1*k2);
	    }
	  else
	    {
	      x=atoi(&c[i]);
	      ireru(x);
	      
	    }
	}
      i++;
    }
  printf("%d\n",stack[0]);
 */



Measured memory_bytes: 2108