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

int top, s[300];

void push(int n)
{
  top++;
  s[top] = n;               //上に積む
}

int pop()
{
  top--;
  return s[top + 1];        //積んだものを返す
}

int main(void)
{
  int i, j, n;
  char s[100];
  top = 0;

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

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

  return 0;
}

