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