#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 1000
#define C 100

int top,S[N];

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

int pop() {

  top--;

  return S[top+1];
} 

int main(void) {

  int a,b;
  top = 0;
  char c[C];

  while(scanf("%s",c) != EOF) {
    if(c[0] == '+') {
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(c[0] == '-') {
      b = pop();
      a = pop();
      push(a-b);
    }
    else if(c[0] == '*') {
      a = pop();
      b = pop();
      push(a*b);
    }
    else {
      push(atoi(c));
    }
  }
  printf("%d\n",pop());

  return 0;
}