#include <iostream>
#include <string>

using namespace std;

struct Node {
    char c;
    Node* left = NULL;
    Node* right = NULL;
};

Node* buildTree(int& index, string str) {
    if (str[index] == '#') {
        index++;
        return NULL;
    } else {
        Node* p = new Node();
        p->c = str[index];
        index++;
        p->left = buildTree(index, str);
        p->right = buildTree(index, str);
        return p;
    }
}

void InOrder(Node* p) {
    if (p == NULL) {
        return ;
    } else {
        InOrder(p->left);
        printf("%c ", p->c);
        InOrder(p->right);
    }
}

int main() {
    string str;
    getline(cin, str);
    int index = 0;
    Node* root = buildTree(index, str);
    InOrder(root);
}