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

#define MAX 500

int stack[MAX];
int top = 0;

void push(int);
int pop(void);
int cul(char *);
int num(char *);

int main(){
  char a,s[MAX];
  int i;
  
  scanf("%[^\n]*s",s);
  
  printf("%d\n",cul(s));
  
  return 0;
} 
  
int cul(char *s){
  int a,b,i;
  
  while(*s){

    if(*s >= '0' && *s <= '9'){
      a = num(s);
      push(a);
      
      while(*s == '-' || *s == '+'){
        s++;
      }
      while(a != 0){
	a /= 10;
	s++;
      }
    
    }else{
      
     if(*s == '+'){
      b = pop();
      a = pop();
      push(a+b);
     }
     else if(*s == '-'){
      b = pop();
      a = pop();
      push(a-b);
     }
     else if(*s == '*'){
      b = pop();
      a = pop();
      push(a*b);
     }
     s++;
   }
  }
  return pop(); 
}

void push(int a){
  stack[top++] = a;
 }

int pop(){
  
  return stack[--top];
}

int num(char *s){
   int a = 0;
   
   if(*s == '+' || *s == '-'){
     s++;
   }

   while(*s >= '0' && *s <= '9'){
      a = (a * 10) + (*s - '0');
      s++;
   }
   return a;
}


