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

#define MAX 1000

int S[MAX];
int top;
char s[MAX];

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

int main()
{
  int a,b,x;
  char s[100];

  while( scanf("%s", s) != EOF )
  {
    if( s[0] == '+' )
    {
      a = pop();
      b = pop();
      push(a + b);
    } 
    else if( s[0] == '-' )
    {
      a = pop();
      b = pop();
      push(b - a);
    }
    else if( s[0] == '*' )
    {
      a = pop();
      b = pop();
      push(a * b);
    }
    else
    {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());

  return 0;
}

void initialize()
{
  top = 0;
}

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

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

void push(int x)
{
  if(isFull())
  {
    fprintf(stderr, "??¨?????????????????????????????????\n");
    exit(1);
  }
  else
  {
    top++;
    S[top]=x;
  }
}

int pop()
{
  if(isEmpty())
  {
    fprintf(stderr,"??¨???????????¢?????????????????????\n");
    exit(1);
  }
  else
  {
  top--;
  return S[top+1];
  }
}