#include<bits/stdc++.h>
using namespace std;
struct node{
int d;
char c;
};
char c[1100];
bool t[1100];
stack<node> s;
int main(){
cin >>c;
int len=strlen(c);
for(int i=0;i<len;i++){
if(s.empty()){ //当栈为空时无法进行以下的操作
s.push({i,c[i]}); //将(i,c[i])入栈
continue;
}
node tmp=s.top(); //读取栈顶元素
s.push({i,c[i]}); //将(i,c[i])入栈
if(s.top().c==')' && tmp.c=='('){
s.pop();
s.pop();
t[i]=true;
t[tmp.d]=true;
}
else if(s.top().c==']' && tmp.c=='['){
s.pop();
s.pop();
t[i]=true;
t[tmp.d]=true;
}
}
for(int i=0;i<len;i++){
if(t[i]==true){
cout <<c[i];
}
else{
if(c[i]=='(' || c[i]==')'){
cout <<"()";
}
else if(c[i]=='[' || c[i]==']'){
cout <<"[]";
}
}
}
return 0;
}