#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 ch){
     return (ch == '+' || ch == '-' || ch == '*' || ch == '\');
 }
 
 int main(){
     char prefix[MAX];
     scanf("%s",prefix);
     
     int len = strlen(prefix);
     for(i=len - 1; i>=0 ; i--){
         if(isalnum(prefix[i])){
             char op[2];
             op[0]=prefix[i];
             op[1]='\0';
             push(op);
         }
         else if(isOperator(prefix[i])){
             if(top < 1){
                 printf("Invalid input");
                 return 0;
             }
             char a[MAX],b[MAX],temp[MAX];
             strcpy(a,pop());
             strcpy(b,pop());
             
             strcpy(temp, a);
             strcpy(temp, b);
             int l= strlen(temp);
             temp[l]=prefix[i];
             temp[l + 1]='\0';
             
             push(temp);
         }
         else{
             printf("Invalid input");
             return 0;
         }
     }
     
     if(top !=0){
         printf("Invalid inpu")
     }
 }