#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define max 200

char s[max][max];
int top=-1;
void push(char *str)
{
    strcpy(s[++top],str);
}
char* pop()
{
    return s[top--];
}
int isop(char c)
{
    return ( c == '+'||c == '-'||c == '*'||c == '/');
}
void reverse(char *str)
{
    int i=0,j=strlen(str)-1;
    while(i<j)
    {
        char t = str[i];
        str[i]=str[j];
        i++;
        j; 
    }
}
int main()
{
    char p[max];
    fgets(p,max,stdin);
    int len = strlen(p);
    for(int i=len-1;i>=0;i--)
    {
        char ch = p[i];
        
        if(ch == ' ')
        {
            continue;
        }
        
        if(ch == '(' || ch == ')')
        {
            printf("Invalid input");
            return 0;
        }
        
        if(isalpha(ch))
        {
            char temp[2] = {ch,'\0'};
            push(temp);
}
else if (isop(ch))
{
    if(top<1)
    {
        printf("Invalid input");
            return 0;
    }
    char op1[max],op2[max],expr[max*2];
    strcpy(op1,pop());
    strcpy(op2,pop());
    snprintf(expr,sizeof(expr),"%s%s%c",op1,op2,ch);
    push(expr);
}
else
{
     printf("Invalid input");
            return 0;
}
}
if(stack.top == 0)
{
 printf("%s\n",stack.items[stack.top]);
}
else{
printf("Invalid input");
}
return 0;
}