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

int c2i(char);

int main(){
  int i=0,top=0,x;
  int stack[1000];
  char s[1000];
  scanf("%[^\n]",s);
  
  while(s[i]!='\0'){
    
    if(48<= (int)s[i] && (int)s[i] <=57){

      if(48<= (int)s[i-1] && (int)s[i-1] <=57){
	x=c2i(s[i]);
	stack[top-1]=(stack[top-1]*10)+x;
      }
      else {
	stack[top]=c2i(s[i]);
	top++;
      }
    }

    else if(s[i]=='+'){
      stack[top-2]=stack[top-2]+stack[top-1];
      top--;
    }
    else if(s[i]=='-'){
      stack[top-2]=stack[top-2]-stack[top-1];
      top--;
    }
    else if(s[i]=='*'){
      stack[top-2]=stack[top-2]*stack[top-1];
      top--;
    }
    i++;
    
  }
  printf("%d\n",stack[top-1]);
  return 0;
}

int c2i(char c){

  return c-'0';
}
 

