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


int Sum(int *A, int a){
    return A[a - 2] + A[a - 1];
}
int Diff(int *A, int a){
    return A[a - 2] - A[a - 1];
}
int Prod(int *A, int a){
    return A[a - 2] * A[a - 1];
}
/*
 * 
 */
int main(int argc, char** argv) {
    
    int A[105];
    char C;
    char Storage[6];
    int PrevIsOperator, lim = 0;
    
    
    for(int a = 0;;){
        
        
    C = getchar();
    if(C == '\n')break;
    if(C == '+'){
        PrevIsOperator = 1;
        A[a-2] = Sum(&A,a);
        a = a - 1;
        continue;
    }
    
    if(C == '-'){
        PrevIsOperator = 1;
        A[a-2] = Diff(&A,a);
        a = a - 1;
        continue;
    }
    
    if(C == '*'){
        PrevIsOperator = 1;
        A[a-2] = Prod(&A,a);
        a = a - 1;
        continue;
    }
    
    if(isspace(C) && PrevIsOperator == 1)continue;
    if(isspace(C) && PrevIsOperator == 0){
        Storage[lim++] = '\n';
        A[a] = atoi(Storage);
        lim = 0;
        a++;
    }
    
    if(isdigit(C)){
        PrevIsOperator = 0;
        Storage[lim++] = C;
        continue;
    }
    }
    
    printf("%d\n",A[0]);
   
    

    return (0);
}

