#include<stdio.h>
#include<ctype.h>
#include<string.h>
#define MAX 25

char stack[MAX][MAX];
int top=-1;

void push(char ch[]) {
    strcpy(stack[++top], ch);
}
 
 char* pop() {
     return stack[top--];
 }
 
 int isOperator(char ch) {
     return (ch=='+' || ch=='-' || ch=='*' || ch=='/');
 }
 
 int isValid(char ch) {
     return (isalnum(ch) || ch=='+'  || ch=='-' || ch=='*' || ch=='/' ||ch=='('|| ch==')');
 }
 
 void fun(char *str) {
     int len=strlen(str), ind;
     for(ind=len-1;ind>=0;ind--){
         char ch=str[ind];
         if(!isValid(ch)) {
             printf("Invalid input");
             return;
         }
         if(isalnum(ch)) {
             char temp[2];
             temp[0] = ch;
             temp[1] = '\0';
             push(temp);
         }
         else if(isOperator(ch)) {
             char opd1[MAX], opd2[MAX], res[MAX];
             strcpy(opd1, pop());
             strcpy(opd2, pop());
             strcpy(res, opd1);
             strcat(res, opd2);
             int 1= strlen(res);
             res[1]=ch;
             res[1+1] ='\0';
             push(res);
         }
     }
     printf("%s", stack[top]);
 }
 int main() {
     char str[MAX];
     scanf("%[^\n]s",str);
     fun(str);
     return 0;
 }
 }
         }
         }
     }
 }