#include <iostream>
#include <string>
using namespace std;
string s;
typedef struct tree {
    char d;
    struct tree* l, * r;
}* t;
tree* fun(int& i) {//i值一直累计
    if (s[i] == '#')return NULL;
    tree* root = new tree();
    root->d = s[i];
    root->l = fun(++i);
    root->r = fun(++i);
    return root;
}
void order(tree* root) {
    if (root == NULL )return;
    order(root->l);
    cout << root->d << " ";
    order(root->r);

}
int main() {
    cin >> s;
    int i = 0;
    tree* root = fun(i);
    order(root);
}