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