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

int top;
int S[N];

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

int pop(){
  top--;
  return S[top+1];
}
int main(){
  int i,j;
  top = 0;
  char s[A];

  while( scanf("%s", s) != EOF){
    if ( s[0] == '+' ){
      i = pop();
      j = pop();
      push(j + i);

    } else if ( s[0] == '-' ){
      i = pop();
      j = pop();
      push(j - i);

    } else if ( s[0] == '*' ){
      i = pop();
      j = pop();
      push(j * i);

    } else {
      push(atoi(s));

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

  return 0;
}

