#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define max 100
char stack[max][max];
int top=-1;
void push(char *str){
    strcpy(stack[++top],str);
}
char *pop(){
    return stack[top--];
}
int isoperator(char c){
    return(c=='+'||c=='-'||c=='*'||c=='/');
}
int main(){
    char prefix[max],op1[max],op2[max],temp[max];
    int i;
    scanf("%s",prefix);
    int len=strlen(prefix);
    for(int i=len-1;i>=0;i--){
        char c=prefix[i];
        if(isalnum(c)){
            char str[2]={c,'\0'}
            push(str)
        }
        else if(isoperator(c)){
            if(top<1){
                printf("Invalid input\n");
                return 0;
            }
            strcpy(op1,pop());
            strcpy(op2,pop());
            strcpy(temp,op1);
            strcpy(temp,op2);
            int len_temp=strlen(temp);
            temp[len_temp]=c;
            temp[len_temp+1]='\0';
            push(temp);
        }
        else{
            printf("Invalid input\n");
            return 0;
        }
    }
    if(top!=0){
        printf("Invalid input\n");
        return 0;
    }
    printf("%s\n",pop());
    return 0;
}