#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef struct{
  int stk[1000];
  int top;
}Stack;

Stack S;

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

int main(){
  char str[100];
  char *ope, *s;
  int a,b,len;
  int i;

  fgets(str,100,stdin);
  len = strlen(str)+1;
  
  s = str;
  
  for(i=0; i<len; i++){
    if(str[i]==' ' || str[i]=='\0'){
      str[i] = '\0';
      strcpy(ope,s);

      if(atoi(s)!=0){
	push(atoi(s));
      }
      
      else{
	switch(s[0]){
	case '+':
	  a = pop();
	  b = pop();
	  push(a+b);
	  break;
	  
	case '-':
	  a = pop();
	  b = pop();
	  push(b-a);
	  break;
	  
	case '*':
	  a = pop();
	  b = pop();
	  push(a*b);
	break;
	
	default:
	  break;
	}
      }

      s = &str[i+1];
    }
    
  }

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

int isEmpty(){
  if(S.top == 0)
    return 1;
  else
    return 0;
}

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

int pop(){
  if(isEmpty()){
    fprintf(stderr,"underflow!!\n");
    exit(8);
  }

  else
    S.top--;
  
  return S.stk[S.top + 1];
}

