#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 (int i=len;i>=0;i++){
         if(isalunum(prefix[i])){
             char op[2];
             op[0]=prefix[i];
             op[1]='\0';
             push(op);
         }
         else if(isOpertor(prefix[i])){
             if(top<1){
                 printf("Invalid input");
                 return 0;
             }
             char a[MAX],b[MAX],temp[MAX];
             strcoy(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 input");
     }
     else{
         printf("%s",stack[top]);
     }
     return 0;
 }