#include<iostream>
#include<stack>
using namespace std;
const int N = 110;
stack<int> pos;
char s[N];
int st[N];
int main(){
cin >> s + 1;
for(int i = 1; s[i]; i ++)
if(s[i] == '[' || s[i] == '(') pos.push(i);
else if(pos.size()){
int j = pos.top();
if(s[j] == '[' && s[i] == ']' || s[j] == '(' && s[i] == ')'){
st[j] = st[i] = 1;
pos.pop();
}
}
for(int i = 1; s[i]; i ++){
if(st[i]) cout << s[i];
else{
if(s[i] == '[' || s[i] == ']') cout << "[]";
else cout << "()";
}
}
return 0;
}