#include <stdio.h>
#include <stdlib.h>
#define N 100

void push(int);
int pop();

int stack[N],top=0;
int main() {
  char S[N];
  int i,n=0,x,y,z;


  while (scanf("%s",S)!=EOF) {
    if (S[0] == '+') {
      y = pop();
      z = pop();
      push(y+z);
    }
    else if (S[0] == '-') {
      /* code */
      y = pop();
      z = pop();
      push(z-y);
    }
    else if (S[0] == '*') {
      /* code */
      y = pop();
      z = pop();
      push(y*z);
    }
    else if (S[0] >= '0' && S[0] <= '9') {
      x = atoi(S);
      push(x);
    }
  }
  printf("%d\n",stack[top] );
  return 0;
}
void push(int x){
  top++;
  stack[top] = x;
}

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

