#include <stdio.h>
#include <string.h>
#include <ctype.h>


char stack[100][100];
int top = -1;


void push(char *str) {
    strcpy(stack[++top], str);
    
}

char* pop() {
    return stack[top--];
}

int isValid(char exp){
    if(exp == '^'||exp == '*' || exp == '/'||exp == '+' ||
    exp == '-'|| exp == '('|| exp == ')') return 1;
    else if(isalnum(exp)){
        return 1;
    }
    return 0;
}

void prefixToPostfix(char* exp) {
    int len = strlen(exp);
    for(int i = len - 1; i >= 0; i--) {
        char c = exp[i];
        if(isalnum(c)) {
            char op[2] = {c, '\0'};
            push(op);
        }
        else {
            char op1[100], op2[100], res[100];
            strcpy(op1, pop());
            strcpy(op2, pop());
            sprintf(res, "%s%s%c", op1, op2, c);
            push(res);
            
        }
        
    }
    printf("%s", stack[top]);
    
}

int main() {
    char exp[100];
    scanf("%s", exp);
    int len=strlen(exp);
    for(int i=0;i<len;i++){
        if(!isValid(exp[i])){
            printf("Invalid input");
            return 0;
        }
    }
    prefixToPostfix(exp);
    return 0;
}