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

#define OPEMAX (10000000)

struct stack{
  int index;
  double ope[OPEMAX];
} stackope;

char *getstringcopy(char *str)
{
  char *cpdata = (char*)malloc(sizeof(char)*strlen(str));
  strcpy(cpdata,str);
  return cpdata;
}

char **getformula()
{
  int i, c, ci;
  char **formula = (char**) malloc(sizeof(char*)*500);
  char el[20];

  i = 0;
  ci = 0;
  while ( -1 )
  {
    c = getchar();
    if (c == ' ' || c == '\n')
    {
        el[ci]='\0';
        formula[i] = getstringcopy(el);
        ci = 0;
        i++;
        if (c == '\n') break;
    }
    else
    {
      el[ci]= c;
      ci++;
    }
  }
  formula[i]=NULL;
  return formula;
}

int countel(char **formula)
{
  int i;
  for(i=0; formula[i] != NULL; i++);
  return i;
}
void initstackope(void)
{
  stackope.index = 0;
}

void pushope(double ope)
{
  stackope.ope[stackope.index] = ope;
  stackope.index++;
}

double popope(void)
{
  stackope.index--;
  return (stackope.ope[stackope.index]);
}


void freeformula(char **formula)
{
  for(int i=0; formula[i] != NULL; i++)
    free(formula[i]);

  free(formula);
}

double calcope(char rator, double a, double b)
{
  if (rator == '+')
    return (a + b);
  else if (rator == '-')
    return (b - a);
  else if (rator == '*')
    return (b*a);
  else if (rator == '/')
    return (b/a);

  return (a+b);
}

double calcpo(char **formula)
{
  int count = countel(formula);

  for(int i=0; i < count; i++)
  {
    if('0' <= formula[i][0] && formula[i][0] <= '9')
    {
      pushope(atof(formula[i]));
    }else{
      double a,b;
      a = popope();
      b = popope();
      a = calcope(formula[i][0], a, b);
      pushope(a);
    }
  }

  return (popope());
}

int main(void)
{
  char **formula;
  double res;
  formula = getformula();
  int count = countel(formula);
  
  printf("%d\n",(long)calcpo(formula));
  freeformula(formula);

}

