#include<stdio.h>
#include<string.h>
#include<ctype.h>
char stack[100][100];
int top = -1;
void push(char *s){ strcpy(stack[++top],s); }
int isOp(char c){ return c=='+' || c == '-' || c == '*' || c == '/' || c == '^'; }
int main() {
    char exp[100];
    fgets(exp,100,stdin);
    exp[strcspn(exp,"\n")] = 0;
    int n=strlen(exp);
    for(int i=n-1;i>=0;i--) {
        char c=exp[i];
        if(c == ' ' || c == '\t') continue;
        if(isalnum(c)) {
            char t[2]={c,'\0'};
            push(t);
         }else if(isOp(c)){
             if(top<1){printf("Invalid input");return 0; }
             char a[100],b[100],t[100];
             if(isalnum(c)) {
                 char t[2];
                 t[0] = c;
                 t[1] = '\0';
                 push(t);
            }
         }else if(!)
         }
    } isOp(c) && !isalum(c) && c!= ' ' && c!= '\t' {
        printf("Invalid input");
        return 0;
    }
    if(top!=0){ printf("Invalid input");
    return 0; }
    printf("%s",stack[top]);
    return 0;
}