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

#define MAX 200

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

int top;
int data[MAX];

int main(){
 int a;
 int b;
 int i;
 char c[MAX];
 int count=0;
 int answer=0;
 
 for(i=0;c[i]!='\n';i++){
 scanf("%c",&c[i]);
 count++;
 }
 
 i=0;
 
 while(i!=count){
      if(c[i]=='+'){
      a=pop();
      b=pop();
      answer = answer + a + b;
      initialize();
      }
    else if(c[i]=='-'){
         a=pop();
      b=pop();
      answer = answer + a - b;
      initialize();
      }
    else if(c[i]=='*'){
         a=pop();
      b=pop();
      answer = answer + a * b;
      initialize();
      }
    else if('0'<=c[i] && c[i]<='9'){ 
         push(c[i]-48);
         }
    else{
         continue;
    }
         i++;
   }
 
 printf("%d\n",answer);
 
 return 0;
}
void initialize(void){
 top=0;
}
int isEmpty(void){
 if(top==0) return -1;
 return top;
}
int isFull(void){
    if(top >= MAX - 1) return -1;
    return top;
}
void push(int x){
   if(isFull()==-1){
   fprintf(stderr,"Overflow!\n");
   exit(1);
   }
   else{
   top++;
   data[top] = x;
   }
}
int pop(){
   if(isEmpty()==-1){
   fprintf(stderr,"Underflow!\n");
   exit(2);
   }
   else top--;
   return data[top+1];
   }