#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>
#define MAX 25

char stack[MAX][MAX];
int top=-1;

void push(char str[]){
    strcpy(stack[++top],str);
}
char* pop(char str[]){
    strcpy(str,stack[top--]);
}
int isOperators( char ch){
    return (ch=='+' || ch=='-' || ch=='*' || ch=='/');
}
int main(){
    char prefix[MAX];
    scanf("%s",prefix);
    int len=strlen(prefix);
    for(int i=len-1;i>=0;i--){
        char ch=prefix[i];
        if(isalnum(ch)){
            char temp[2];
            temp[0]=ch;
            temp[1]='\0';
            push(temp);
        }
        else if(isOperator(ch))
        {
            if(top<1){
                printf("Invalid input");
                return 0;
            }
            char op1[MAX],op2[MAX],result[MAX];
            pop(op1);
            pop(op2);
            strcpy(result.op1);
            strcat(result,op2);
            int 1=strlen(result);
            result[1]=ch;
            result[l+1]='\0';
            push(result);
        }
        else{
            printf("Invalid input");
            return 0;
            
        }
    }
    if(top==0)
    printf("%s",stack[top]);
    else
    printf("Invalid input");
    return 0;
}