#include<iostream>
#include<cstring>
using namespace std;
void Complete(const string &s){
int a;
int i;
a = s.length();
for(i = a - 1; i >= 0; i--){
if(s[i] == ')'){
if(i > 0 && s[i-1] == '('){
cout << "()";
i--;
}
else{
cout << "()";
}
}
if(s[i] == ']'){
if(i > 0 && s[i-1] == '['){
cout << "[]" ;
i--;
}
else{
cout << "[]" ;
}
}
if(s[i]=='('){
cout<<"()";
}
if(s[i]=='['){
cout<<"[]";
}
}
}
int main(){
string s;
cin >> s;
Complete(s);
return 0;
}