#include <bits/stdc++.h>
using namespace std;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0),cout.tie(0);
deque<char> left;
deque<char> right;
string s;
while (cin >> s)
{
bool r = true;
for (char c : s)
{
if (c == '[')
{
r = true;
}
else if (c == ']')
{
r = false;
}
else
{
if (r)
{
left.push_back(c);
}
else
{
right.push_back(c);
}
}
}
while (!left.empty())
{
cout << left.back();
left.pop_back();
}
while (!right.empty())
{
cout << right.front();
right.pop_front();
}
cout << endl;
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKaW50IG1haW4oKQp7CiAgICBpb3M6OnN5bmNfd2l0aF9zdGRpbygwKTsKICAgY2luLnRpZSgwKSxjb3V0LnRpZSgwKTsKICAgIGRlcXVlPGNoYXI+IGxlZnQ7CiAgICBkZXF1ZTxjaGFyPiByaWdodDsKICAgIHN0cmluZyBzOwogCiAgICB3aGlsZSAoY2luID4+IHMpCiAgICB7CiAgICAgICAgYm9vbCByID0gdHJ1ZTsKIAogICAgICAgIGZvciAoY2hhciBjIDogcykKICAgICAgICB7CiAgICAgICAgICAgIGlmIChjID09ICdbJykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgciA9IHRydWU7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZiAoYyA9PSAnXScpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHIgPSBmYWxzZTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGlmIChyKQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGxlZnQucHVzaF9iYWNrKGMpOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICAgICAgZWxzZQogICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIHJpZ2h0LnB1c2hfYmFjayhjKTsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KIAogCiAgICAgICAgd2hpbGUgKCFsZWZ0LmVtcHR5KCkpCiAgICAgICAgewogICAgICAgICAgICBjb3V0IDw8IGxlZnQuYmFjaygpOwogICAgICAgICAgICBsZWZ0LnBvcF9iYWNrKCk7CiAgICAgICAgfQogICAgICAgIHdoaWxlICghcmlnaHQuZW1wdHkoKSkKICAgICAgICB7CiAgICAgICAgICAgIGNvdXQgPDwgcmlnaHQuZnJvbnQoKTsKICAgICAgICAgICAgcmlnaHQucG9wX2Zyb250KCk7CiAgICAgICAgfQogICAgICAgIGNvdXQgPDwgZW5kbDsKICAgIH0KIAogICAgcmV0dXJuIDA7Cn0KIA==