#include<stdio.h>
#include<stdlib.h>
void push(int);
int pop(void);

int s[100],top = 0;

int main()
{
  char c;

  while(scanf("%c",&c) != EOF) {
    switch(c) {
    case '+':
      push(pop()+pop());
      break;
    case '-':
      push(pop()-pop());
      break;
    case '*':
      push(pop()*pop());
      break;
    case ' ':
      break;
    default:
      push(atoi(&c));
      break;
    }
  }
  printf("%d\n",s[1]);
  return 0;
}

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

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