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

static int pos = 0;
static int stack[100];

void push(int i){
  stack[pos++] = i;
}

int pop(void){
  return stack[--pos];
}

int main(void){
  char str[16];

  while (scanf("%s ", str) != EOF){
    int a,b;
    switch (str[0]) {
    case '*':
    case '+':
    case '-':
      a = pop();
      b = pop();
      if (str[0] == '*')
        push(b*a);
      else if (str[0] == '+')
        push(b+a);
      else if (str[0] == '-')
        push(b-a);
      break;
    default:
      push (atoi(str));
      break;
    }
  }
    printf("%d\n", pop());
  return 0;
}