  #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++;
	
}