#include<bits/stdc++.h>
#define str to_string
using namespace std;
using ll=long long;
const int MAX=1e5+1;
string s;
bool book[MAX];
int main(){
cin>>s;
int len=s.size();
for(int i=0;i<len;i++){
if(s[i]==')'){
int j=i;
while(j--){
if(s[j]=='[')break;
if(s[j]=='('&&!book[j]){
book[i]=true;
book[j]=true;
break;
}
}
}else if(s[i]==']'){
int j=i;
while(j--){
if(s[j]=='(')break;
if(s[j]=='['&&!book[j]){
book[i]=true;
book[j]=true;
break;
}
}
}
}
for(int i=0;i<len;i++){
if(book[i])cout<<s[i];
else if(s[i]=='('||s[i]==')')cout<<"()";
else if(s[i]=='['||s[i]==']')cout<<"[]";
}
return 0;
}