// editor4
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define MAX 100
char stack[MAX][MAX];
int top = -1;
void push(char str[]){
    if (top < MAX - 1){
        top++;
        strcpy(stack[top], str);
    }
}
char* pop(){
    if(top >= 0){
        return stack[top--];
    }
    return NULL;
}
int isOperator(char ch){
    return (ch == '+' || ch == '-' || ch == '*' || ch == '/');
}
int main(){
    char prefix[MAX];
    scanf("%s", prefix);
    int len = strlen(prefix);
    for(int i=len - 1;i>=0;i--){
        char ch = prefix[i];
        if(isalnum(ch)){
            char operand[2];
            operand[0] = ch;
            operand[1] = '\0';
            push(operand);
        }
        else if(isOperator(ch)){
            if(top < 1){
                printf("Invalid input");
                return 0;
            }
            char op1[MAX], op2[MAX], temp[MAX];
            strcpy(op1, pop());
            strcpy(op2, pop());
            strcpy(temp, op1);
            strcpy(temp, op2);
            int l = strlen(temp);
            temp[l] = ch;
            temp[l + 1] = '\0';
            push(temp);
        }
        else{
            printf("Invalid input");
            return o;
        }
    }
    if(top == 0)
        printf("%s", pop());
    else
        printf("Invalid input");
    return 0;
}