#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>

#define MAX 100

char stack[MAX];
int top=-1;

void push(char ch){
    stack[++top] = ch;
}

char pop(){
    return stack[top--];
}

char peek(){
    return stack[top];
}

int isOperator(char ch){
    return ch == '+' || ch == '-' || ch == '*' || ch == '/';
}

int precedence(char ch){
    if(ch == '+' || ch == '-') return 1;
    if(ch == '*' || ch == '/') return 2;
    return 0;
}

int isValid(char ch){
    return isalnum(ch) || isOperator(ch) || ch == '(' || ch == ')';
}

int isBalance(char *expr){
    int count = 0;
    for(int i=0; expr[i]; i++){
        if(expr[i] == '(') count++;
        else if(expr[i] == ')') count--;
        if(count < 0) return 0;
    }
    return count ==0;
}

int main(){
    char expr[MAX];
    scanf("%s", &expr);
    
    for(int i=0; expr[i]; i++){
        if(!isValid(expr[i])){
            printf("Invalid input\n");
            return 0;
        }
    }
    if(!isBalance(expr)){
        printf("Invalid input\n");
        return 0;
    }
    char postfix[MAX];
    int k=0;
    
    for(int i=0; expr[i]; i++){
        char ch = expr[i];
        if(isalnum(ch)){
            postfix[k++] = ch;
        }
        else if(ch == '('){
            push(ch);
        }
        else if(ch == ')'){
            while(top!=-1 && peek() !='('){
                postfix[k++] = pop();
            }
            if(top!=-10) pop();
        }
        else if(isOperator(ch)){
            while(top != -1 && precedence(peek()) >= precedence(ch)){
                postfix[k++] = pop();
        }
        
        push(ch);
    }
 }
 while(top!=-1){
     postfix[k++] = pop();
 } 
 postfix[k] = '\0';
 printf("%s\n",postfix);
 return 0;
}