#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define max 25

char stack[max][max],top = -1;

void push(char str){
    if(top==max-1){
        printf("Stack overflow");
        exit(0);
    }
    else{
        strcpy(stack[++top], str);
    }
}

char pop(){
    if(top==-1){
        printf("Stack underflow");
        return 0;
    }
    else{
        return stack[top--];
    }
}

void func(char str[]){
    int len = strlen(str),chlen;
    char ch;
    for(int i=0;i<len;i++){
        ch = str[i];
        if(isalnum(ch)){
            char temp[2];
            temp[0] = ch;
            temp[1] = '\0';
            push(temp);
        }
        else{
            char op1[max],op2[max],res[max];
            strcpy(op1,pop());
            strcpy(op2,pop());
            strcat(res, op1);
            strcat(res,op2);
            chlen = strlen(res);
            push(res);
            
        }
        printf("%s",stack[top]);
    }
}

int main(){
    char str[max];
    scanf("%s",str);
    func(str);
}