#include<iostream>
#include<deque>
using namespace std;
deque<string> q;
void trans(string x){
if(x.length()>0){
if(x[0]=='['){
int i =1;
while(x[i]!='[' && x[i]!= ']' && i<x.length())i++;
q.push_front(x.substr(1,i-1));
trans(x.substr(i)+"");
return;
}else if(x[0]==']'){
int i =1;
while(x[i]!='[' && x[i]!= ']' && i<x.length())i++;
q.push_back(x.substr(1,i-1));
trans(x.substr(i));
return;
}else{
char h[]={x[0]};
string hh(h);
q.push_back(hh);
trans(x.substr(1));
return;
}
}
}
int main(){
string xs;
cin>>xs;
trans(xs);
deque<string>::iterator it = q.begin();
while(it!= q.end())
cout<<*it++;
}
ICAjaW5jbHVkZTxpb3N0cmVhbT4KI2luY2x1ZGU8ZGVxdWU+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmRlcXVlPHN0cmluZz4gcTsKCnZvaWQgdHJhbnMoc3RyaW5nIHgpewogICAgaWYoeC5sZW5ndGgoKT4wKXsKICAgIGlmKHhbMF09PSdbJyl7CiAgICAgICAgaW50IGkgPTE7CiAgICAgICAgd2hpbGUoeFtpXSE9J1snICYmIHhbaV0hPSAnXScgJiYgaTx4Lmxlbmd0aCgpKWkrKzsKICAgICAgICBxLnB1c2hfZnJvbnQoeC5zdWJzdHIoMSxpLTEpKTsKICAgICAgICB0cmFucyh4LnN1YnN0cihpKSsiIik7CiAgICAgICAgcmV0dXJuOwogICAgfWVsc2UgaWYoeFswXT09J10nKXsKICAgIAlpbnQgaSA9MTsKICAgICAgICB3aGlsZSh4W2ldIT0nWycgJiYgeFtpXSE9ICddJyAmJiBpPHgubGVuZ3RoKCkpaSsrOwogICAgICAgIHEucHVzaF9iYWNrKHguc3Vic3RyKDEsaS0xKSk7CiAgICAgICAgdHJhbnMoeC5zdWJzdHIoaSkpOwogICAgICAgIHJldHVybjsKICAgIH1lbHNlewoJY2hhciBoW109e3hbMF19OwoJc3RyaW5nIGhoKGgpOwoJcS5wdXNoX2JhY2soaGgpOwoJdHJhbnMoeC5zdWJzdHIoMSkpOwoJcmV0dXJuOwogICAgfQp9Cn0KCmludCBtYWluKCl7CnN0cmluZyB4czsKY2luPj54czsKdHJhbnMoeHMpOwpkZXF1ZTxzdHJpbmc+OjppdGVyYXRvciBpdCA9IHEuYmVnaW4oKTsKd2hpbGUoaXQhPSBxLmVuZCgpKQpjb3V0PDwqaXQrKzsKCQp9