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