#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000

void push(int);
int pop();
void isEmpty();
void isFull();

int top,stac[MAX];

int main(){
  int x;
  int n1=0,n2=0;
  char s[100];
  top=0;
  
  while( scanf("%s", s) != EOF ){

    if ( s[0] == '+' ){
      if(top==0) isEmpty();
      else if(top>=MAX-1) isFull();
      n2=pop();
      n1=pop();

      push(n1+n2);
      
    } else if ( s[0] == '-' ){
      if(top==0) isEmpty();
      else if(top>=MAX-1) isFull();
      n2=pop();
      n1=pop();

      push(n1-n2);
      
    } else if ( s[0] == '*' ){
      if(top==0) isEmpty();
      else if(top>=MAX-1) isFull();
      n2=pop();
      n1=pop();

      push(n1*n2);
      
    } else {
      x = atoi(s);
      push(x);
    }

  }

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


void push(int x){
  if(top>=MAX-1) isFull();

  stac[top]=x;
  top++;
}

int pop(){
  int x;
  if(top==0) isEmpty();
  top--;
  return stac[top];
}

void isEmpty(){
  printf("this stac is empty!\n");
  exit(2);
}

void isFull(){
  printf("this stac is full!\n");
  exit(2);
}

