// editor2
#include<stdio.h>
#include<string.h>
#include<ctype.h>
char stack[100][100];
int top=-1;
void push(char*str){
    strcpy(stack[++top],str);
}
char*pop(){
    return stack[top--];
}
int isop(char c){
    return(c=='+'||c=='-'||c=='*'||c=='/'||c=='^');
}
int main(){
    char pre[100],post[100];
    scanf("%s",pre);
    int n=strlen(pre);
    for (int i=n;i>=0;i--){
        char c=pre[i],a[2]={c,'\0'},x[100],y[100],z[100];
        if(isalum(c)push(a))
        else if(isop(c)){
            if(top<1){
                printf("Invalid input");
                return 0;
            }
            strcpy(x,pop());
            strcpy(y,pop());
            sprintf(z,"%s %s %c",x,y,c);
            push(z);
        }
        else{
            printf("Ivalid input");
            return 0;
        }
        }
        if(top!=0)
        printf("Invalid input");
        else
        printf("%s ",pop());
        return 0;
    }
}