#include<stdio.h>
#define N 199
void enqueue(int);
int dequeue(void);
int top;
int stack[N];
int main(){
  char input[11];
  top = 0;
  while( scanf("%s",input) != EOF ){
    if( input[0] == '+' ){
      stack[top-1] += dequeue();
    }
    else if( input[0] == '-' ){
      stack[top-1] -= dequeue();
    }
    else if( input[0] == '*' ){
      stack[top-1] *= dequeue();
    }
    else {
      enqueue( atoi(input) );
    }
  }
  printf("%d\n",stack[top]);
  return 0;
}
void enqueue(int input){
  stack[++top] = input;
}
int dequeue(void){
  return stack[top--];
}