#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define MAX 100
char stack[MAX][MAX];
int top=-1;
void push(char *str){
    strcpy(stack[++top],str);
}
char* pop(){
    return stack[top--];
}
int isOperator(char c){
    return(c == '+' || c == '-' || c == '*' || c == '/');
}
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 temp[2];
            temp[0]=ch;
            temp[1]='\0';
            push(temp);
        }
        else if(isOperator(ch)){
            if(top<1){
                printf("Invalid input");
                return 0;
            }
            char op1[MAX],op2[MAX],expr[MAX];
            strcpy(op1,pop());
            strcpy(op2,pop());
            sprintf(expr,"%s%s%c",op1,op2,ch);
            push(expr);
        }
        else{
            printf("Invalid input");
            return 0;
        }
    }
    if(top != 0){
        printf("Invalid input");
    }
    else{
        printf("%s",pop());
    }
    return 0;
}