/* وَقُلْ رَبِّ زِدْنِي عِلْمًاً */
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <fstream>
#include <cctype>
#include <utility>
#define ll long long
#define ld long double
#define sz(v) ((int)(v).size())
#define all(v) ((v).begin()),((v).end())
#define setp(n) cout << fixed << setprecision(n)
#define O_o ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define yes cout << "yes\n"
#define no cout << "no\n"
#define fi(nn) for(ll i = 0; i < (nn); i++)
#define fj(nn) for(ll j = 0; j < (nn); j++)
#define fl(nn) for (ll i = nn - 1; i >= 0; i--)
#define ffi(nn,mm) for(ll i = 0; i < (nn); i++)for(ll j = 0; j < (mm); j++)
#define wt ll t;cin>>t;while(t--)
#define null NULL
using namespace std;
string pro(string s) {
deque <string> de;
string now = "";
bool atf = 0;
fi(s.size()) {
if (s[i] == '[') {
if (atf) {
de.push_front(now);
}
else {
de.push_back(now);
}
now = "";
atf = 1;
}
else if (s[i] == ']') {
if (atf) {
de.push_front(now);
}
else {
de.push_back(now);
}
now = "";
atf = 0;
}
else {
now += s[i];
}
}
if (!now.empty()) {
if (atf) {
de.push_front(now);
}
else {
de.push_back(now);
}
}
string res = "";
fi(de.size()) {
res += de[i];
}
return res;
}
int main()
{
O_o
string s;
while (getline(cin, s)) {
cout << pro(s) << '\n';
}
return 0;
}
Lyog2YjZjtmC2Y/ZhNmSINix2Y7YqNmR2ZAg2LLZkNiv2ZLZhtmQ2Yog2LnZkNmE2ZLZhdmL2KfZiyAqLwojaW5jbHVkZSA8aW9zdHJlYW0+CiNpbmNsdWRlIDxhbGdvcml0aG0+CiNpbmNsdWRlIDxjbWF0aD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxzdGFjaz4KI2luY2x1ZGUgPHNldD4KI2luY2x1ZGUgPHF1ZXVlPgojaW5jbHVkZSA8ZG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pIHsKICAgICAgICAgICAgICAgIGRlLnB1c2hfZnJvbnQobm93KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIHsKICAgICAgICAgICAgICAgIGRlLnB1c2hfYmFjayhub3cpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG5vdyA9ICIiOwogICAgICAgICAgICBhdGYgPSAxOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChzW2ldID09ICddJykgewogICAgICAgICAgICBpZiAoYXRmKSB7CiAgICAgICAgICAgICAgICBkZS5wdXNoX2Zyb250KG5vdyk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSB7CiAgICAgICAgICAgICAgICBkZS5wdXNoX2JhY2sobm93KTsKICAgICAgICAgICAgfQogICAgICAgICAgICBub3cgPSAiIjsKICAgICAgICAgICAgYXRmID0gMDsKICAgICAgICB9CiAgICAgICAgZWxzZSB7CiAgICAgICAgICAgIG5vdyArPSBzW2ldOwogICAgICAgIH0KICAgIH0KCiAgICBpZiAoIW5vdy5lbXB0eSgpKSB7CiAgICAgICAgaWYgKGF0ZikgewogICAgICAgICAgICBkZS5wdXNoX2Zyb250KG5vdyk7CiAgICAgICAgfQogICAgICAgIGVsc2UgewogICAgICAgICAgICBkZS5wdXNoX2JhY2sobm93KTsKICAgICAgICB9CiAgICB9CgogICAgc3RyaW5nIHJlcyA9ICIiOwogICAgZmkoZGUuc2l6ZSgpKSB7CiAgICAgICAgcmVzICs9IGRlW2ldOwogICAgfQoKICAgIHJldHVybiByZXM7Cn0KCmludCBtYWluKCkKewogICAgT19vCiAgICAgICAgc3RyaW5nIHM7CiAgICB3aGlsZSAoZ2V0bGluZShjaW4sIHMpKSB7CiAgICAgICAgY291dCA8PCBwcm8ocykgPDwgJ1xuJzsKICAgIH0KICAgIHJldHVybiAwOwp9