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

#define STSIZE 100

int top = 0;
int a[STSIZE];

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

int main()
{
  char s[100];
  int i,j,num,x;
  int k;

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

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

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

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

