#define _CRT_SECURE_NO_WARNINGS 1
#include <bits/stdc++.h>
using namespace std;
typedef struct _node
{
char a;
struct _node* next;
}node;
node* creatheadnode()
{
node* headnode=(node*)malloc(sizeof(node));
headnode->next = NULL;
return headnode;
}
node* creatnewnode(char str)
{
node* newnode=(node*)malloc(sizeof(node));
newnode->a = str;
newnode->next = NULL;
return newnode;
}
void insertnode(node* p, node* newnode)
{
newnode->next = p->next;
p->next = newnode;
}
void shownode(node* headnode)
{
node* point = headnode;
while (point->next != NULL)
{
point = point->next;
printf("%c", point->a);
}
}
void freenode(node* headnode)
{
node* point = headnode;
while (point->next != NULL)
{
node* tmp = point->next;
free(point);
point = tmp;
}
}
char arr[10086]; int len = 0;
int main()
{
while (memset(arr,'\0',sizeof(arr)), scanf("%s", &arr) != EOF)
{
node* headnode = creatheadnode();
len = strlen(arr);
node* p = headnode;
node* end_p = headnode;
for (int i = 0; i < len; i++)
{
if (arr[i] == '[')
{
end_p = p;
p = headnode;
}
else if (arr[i] == ']')
{
p = end_p;
}
else
{
node* newnode = creatnewnode(arr[i]);
insertnode(p, newnode);
p = p->next;
}
}
shownode(headnode);
printf("\n");
freenode(headnode);
}
return 0;
}