#include<stdio.h>
#include<ctype.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;
    char c;
    scanf("%s",infix);
    for(int i=0;infix[i!='\0;i++)
    {
        c=infix[i];
        if(isalnum(c))
        {
            postfix[k++]=c;
        }
        else if(c=='(')
        {
            push(c);       
        }
        else if(c==')')
        {
            while(top!=-1&&stack[top]!='(')
            postfix[k++]=pop();
            if(top!=-1&&stack[top]=='(')
            pop();
            else
            {
                printf("Invalid input\n");
                return 0;
            }
        }
        else if(c=='+'||c=='-'||c=='*'||c=='/')
        {
            while(top!=-1&&precedence(stack[top])>=precedence(c))
                postfix[k++]=pop();
                push(c);
        }
        else
        {
            printf("Invalid input\n");
            return 0;
        }
    }
    while(top!=-1)
    {
        if(stack[top]=='(')
        {
            printf("Invalid input\n");
            return 0;
        }
        postfix[k++]=pop();
    }
    postfix[k]='\0';
    printf("%s\n",postfix);
    return 0;
}