#include<iostream>
#include<string>
using namespace std;

typedef struct TreeNode{
	char val;
	struct TreeNode* left;
	struct TreeNode* right;
}Tree;

int idx = 0;
string str;

void createTree(Tree* &root)
{
	if(str[idx] == '#'){
		idx++;
		root = nullptr;
		return;
	}
	if(root == nullptr){
		root = new Tree();
		root -> val = str[idx++];
	}
	createTree(root -> left);
	createTree(root -> right);
}

void suffixOrder(Tree* root)
{
	if(root == nullptr) return;
	suffixOrder(root -> left);
	cout << root -> val << " ";
	suffixOrder(root -> right);
}

int main(void)
{
	cin >> str;
	Tree* root = nullptr;
	createTree(root);
	suffixOrder(root);
	
	return 0;
}