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

#define N 101

int top,S[N];

int pop(){
  if(top==0){
    fprintf(stderr,"stack is empty");
    exit(2);
  }
  return S[top--];
}

void push(int a){
  if(top==100){
    fprintf(stderr,"stack over flow");
    exit(1);
  }
  S[++top]=a;
}

int main(){
  char in;
  
  S[top]=NULL;

  while(scanf("%c",&in)!=-1){
    if(48<=in&&in<=57){
      
      push(in - '0');
      
    }else{
      switch(in){
      case 42:
	push(pop()*pop());
	break;
      case 43:
	push(pop()+pop());
	break;
      case 45:
	push(-pop()+pop());
	break;
      }
    }
  }
  printf("%d\n",S[top]);
  return 0;
}

