// editor5
#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--];
}
int precedence(char c){
    if(c == '+' || c == '-')return 1;
    if(c == '*' || c == '/')return 2;
    return 0;
}
int main(){
    char infix[MAX],postfix[MAX];
    int i,k = 0,balance = 0;
    scanf("%s",infix);
    for(i=0;i<strlen(infix);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 && stack[top] != '('){
                postfix[k++] = pop();
            }
            pop();
        }
        else if(ch == '+' || ch == '-' || ch == '*' || ch == '/'){
            while(tio != -1 && precedence(stack[top]) >= precedence(ch)){
                postfix[k++] = pop();
            }
            push(ch);
        }
        else{
            printf("Invalid input");
            return 0;
        }
    }
    if(balance != 0){
        printf("Invalid in put");
        return 0;
    }
    while(top !- -1){
        if(stack[top] == '('){
            printf("Invalid input");
            return 0;
        }
        postfix[k++] = pop();
    }
    postfix[k] = '\0';
    printf("%s",postfix);
    return 0;
}