#include <stdio.h>
#include<stdlib.h>
#include <string.h>
#include <ctype.h>
#define MAX_SIZE 1000
typedef struct {
    char array[MAX_SIZE];
    int top;
}charstack;
void initstack(charstack*stack) {
    stack->top=-1;
}

void push(charstack *stack,char value) {
    if(stack->top<MAX_AX-1){
    stack->array[++(stack->top)]=value;
    }
}
char pop(charstack*stack) {
    if(stack->top>=0){
      return stack->array[(stack->top)--];  
    }
    return 0
}
int isEmpty(charstack*stack){
    return stack->top==-1;
}
int isOperator(char c) {
    return c=='+' || c=='-' || c=='*' || c=='/' || c=='^';
}
char*prefixToppostfix(const char*expression){
    static char result[MAX_SIZE];
    charstack stack;
    initstack(&stack);
    int j=0;
for(int i=strlen(expression)-1;i>=0;i--) {
    char c=expression[i];
    if(isalnum(c)){
        push(&stack,c);
    }else if(isOperator(c)){
        if(stack.top<1){
            return "Invalid input";
        }
        char op1=pop(&stack);
        char op2=pop(&stack);
        result[j++]=op1;
        result[j++]=op2;
        result[j++]=c;
        push(&stack,result[j-1]);
    }else{
        return "Invalid input";
    }
    while(!isEmpty(&stack)){
        result[j++]=pop(&stack);
    }
    result[j]='\0';
    for(int k=0;k<j/2;k++){
        char temp=result[k];
        
    }

}
}
int main() {
    char pre[100], t[100], a[100], b[100];
    fgets(pre, 100 ,stdin);
    for (int i = strlen(pre) - 1; i >= 0; i--) {
        if (pre[i] == ' ' || pre[i] == '\n')
        continue;
        if (isalnum(pre[i])) {
            t[0] = pre[i];
            t[1] = '\0';
            push(t);
        }
        else if (isOperator(pre[i])) {
            strcpy(a, pop());
            strcpy(b, pop());
            sprintf(t, "%s%s%c", a, b, pre[i]);
            push(t);
        }
            else {
                printf("Invalid input");
                return 0;
            }
        }
        printf("%s", pop());
        return 0;
    }