#include <stdio.h>
#include <ctype.h>

int stack[100];
int sz;

void push(int x) {
  if(sz == 100) return;
  stack[sz++] = x;
}

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

int main() {
  char c = '\0';
  int a, b;
  while(c != '\n') {
    a = 0;
    while(1) {
      c = getchar();
      if(!isdigit(c)) break;
      a = a*10 + c-'0';
    }
    
    if(c == ' ') {
      push(a);
    } else {
      b = pop();
      a = pop();
      if(c == '+') push(a + b);
      else if(c == '-') push(a - b);
      else if(c == '*') push(a * b);
      c = getchar();
    }
  }
  printf("%d\n", pop());
  return 0;
}